Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
valgrind and python
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
athrpf
n00b
n00b


Joined: 13 Jun 2012
Posts: 1

PostPosted: Wed Jun 13, 2012 7:42 am    Post subject: valgrind and python Reply with quote

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
View user's profile Send private message
aharel
n00b
n00b


Joined: 16 Nov 2011
Posts: 36

PostPosted: Sun May 05, 2013 7:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21586

PostPosted: Sun May 05, 2013 9:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum