How to check for memory leaks in Guile expansion modules

I am developing an extension module for Guile written in C. This extension module includes a Python interpreter.

Since this extension module calls the Python interpreter, I need to make sure that it correctly manages the memory occupied by Python objects.

I found that the Python interpreter behaves well in its own memory handling, so by running valgrind I can find memory leaks due to errors in my own Python interpreter injection code if there are no other interfering factors.

However, when I run Guile under valgrind, valgrind reports memory leaks. Such memory leaks hide any memory leaks due to my own code.

The question is what can I do to separate memory leaks due to errors in my code from memory leaks reported by valgrind due to Guile. Another tool instead of valgrind? Special valgrind options? Stop using manual code?

+4
source share
1 answer

You have a couple of options. One of them is to write a supressions file for valgrind that disables the report of materials you are not working on. Python has a file like this: http://svn.python.org/projects/python/trunk/Misc/valgrind-python.supp

If valgrind doesn't like your setup, another option uses libmudflap ; you compile your program with gcc -fmudflap -lmudflap , and the resulting code will be used to debug the pointer. Described in gcc docs and here: http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging

+5
source

Source: https://habr.com/ru/post/1276782/


All Articles