Debugging memory corruption.
Jakob Schiotz
schiotz2 at yahoo.com
Wed Dec 11 11:12:26 EST 2002
Hi Python gurus,
I am debugging an extension module written in C++, and apparently I
have a memory corruption problem. The module coredumps, depending on
how I call it (see below). Is there a way to make Python check for
memory corruption, such as using an object after its refcount has
become zero; deallocating the same memory twice; etc.?
Some details:
My program coredumps in the exp function, despite the arguments to exp
being reasonable. I am beginning to suspect that the code itself is
being overwritten or something like that. But whether the core dump
occurs depend on the way I call it. In the following dyn is an
instance, it is callable and its __call__ function calls my extension
module. I can call it in two ways, through the fido function or the
fido2 callable class:
def fido(d, n):
sys.stderr.write("\n**** Entered fido\n")
for xxx in xrange(n):
d(1)
class fido2:
def __init__(self, dynamics):
self.dynamics = dynamics
def __call__(self, n):
sys.stderr.write("\n**** Entered fido2.__call__\n")
for xx in xrange(n):
self.dynamics(1)
return
When I do
fido(dyn, 25)
the code works, but if I do
xxx = fido2(dyn)
xxx(25)
it dumps core! Has anybody seen something like this before? I am
definetely getting desperate.
I am using Python 2.2 on a Red Hat 7.3 Linux machine. The extension
module is written in C++ and compiled with Intel's C++ compiler,
generating vectorized (SSE2) code for the Pentium 4 processor. The
coredump occurs in the vmldExp2 function, which appears to be the
(vectorized) exp function.
Thanks for any help!
Jakob Schiotz
Mailing list email: schiotz2 at yahoo.com
(the number is incremented when spammed too much)
Normal email: my last name at fysik dot dtu dot dk
More information about the Python-list
mailing list