View previous topic :: View next topic |
Author |
Message |
athrpf n00b
Joined: 13 Jun 2012 Posts: 1
|
Posted: Wed Jun 13, 2012 7:42 am Post subject: valgrind and python |
|
|
Hi everyone,
I am trying to debug a c++ library that is called from python code (written using boost::python). Valgrind itself works fine for pure c++ programs (after lots of trouble with strlen). However, if I do
Code: | valgrind python myscript.py |
where myscript.py calls the C++ code, valgrind does nothing at all and just lets the program segfault - after the
Code: | *** glibc detected *** /usr/bin/python2.7: free(): invalid next size (fast): 0x00000000011640c0 *** |
there is no output from valgrind.
I tried this on ubuntu, and there it works without problems - memory errors that are raised in the c++ code are caught by valgrind.
Any help would be much appreciated |
|
Back to top |
|
|
aharel n00b
Joined: 16 Nov 2011 Posts: 36
|
Posted: Sun May 05, 2013 7:07 pm Post subject: |
|
|
Found this old thread with google. So for the next person to stumble here, the natural thing to try is to add the flags
Code: | --trace-children=yes |
to the valgrind command line |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21586
|
Posted: Sun May 05, 2013 9:35 pm Post subject: |
|
|
The OP specified nothing about the Python program creating children, so that is likely not the problem. Python defaults to using a custom memory allocator that routinely accesses memory in ways disallowed by normal memory safety rules, causing numerous warnings from Valgrind. Compile Python with the flag --without-pymalloc to switch it to the standard allocator, which does not routinely access free memory. Some versions of Python also support --with-valgrind, which will attempt to auto-detect Valgrind and switch off PyMalloc only when Valgrind is present. |
|
Back to top |
|
|
|