debugging tip - valgrind friendly python

James Henstridge james at jamesh.id.au
Wed Dec 2 11:27:00 GMT 2009


On Wed, Dec 2, 2009 at 1:36 PM, Alexander Belchenko <bialix at ukr.net> wrote:
> Robert Collins пишет:
>> https://edge.launchpad.net/~jamesh/+archive/python
>>
>> these packages have pymalloc disabled, so valgrind gets a more accurate
>> picture of whats happening.
>>
>> YMMV enjoy.
>>
>> Thanks James ;)
>>
>> -Rob
>
> I'm using suppression file for valgrind from Python sources with success. It's enough to test
> failures in C-code invoked from Python.
>
> http://svn.python.org/projects/python/trunk/Misc/README.valgrind

Note that you'll miss out on a lot with those suppressions.  Any
memory allocated through PyObject_Malloc/PyObject_Free may be
allocated from one of pymalloc's memory pools.  Valgrind only sees the
allocations of the larger pools, so won't track those individual
allocations.  All the suppressions do is get rid of the uninitialise
read warnings.  You'll miss out on many potential errors like this.

The packages in my PPA include a patch that gets the interpreter to
detect whether it is running under valgrind or not.  If it is, then
the pymalloc allocator is disabled, with PyObject_Malloc/PyObject_Free
passing through to normal malloc/free, which valgrind knows how to
track.

James.



More information about the bazaar mailing list