tags:

views:

129

answers:

1

Hi All:

I'm using python2.5 with scipy.weave to embed c code.

In my c code, there is no malloc() function, but I received error like

"glibc detected *** python: malloc(): memory corruption"

from time to time.(It's a random algorithm)

So how shall I debug it out?

Thanks

+4  A: 

I'd hazard a guess that your code is overflowing an array somewhere (or causing Python to do so).

You're going to find debugging this to be hard if you can't reliably reproduce it, so you might want to explicitly seed your random number generator and try to find a seed with which you can reproduce the corruption. You might also find that using a tool like valgrind is helpful to track when you write over the limits of an allocation -- probably more so when you can reproduce it every time.

Andrew Aylett
+1 for valgrind
bstpierre