开发者

How to debug "glibc detected *** python: malloc(): memory corruption"

开发者 https://www.devze.com 2023-01-14 22:39 出处:网络
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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消