Valgrind errors when linked with -static — Why?

Does valgrind just not work with -static? It does. The problem is not in Valgrind, it’s in glibc, which is not Valgrind clean. The glibc developers refused to fix these problems (because the problems are of a “don’t care” nature, and fixing them costs (a few) cycles). When you link dynamically, these errors come from … Read more

Valgrind reports errors for a very simple C program

If the programme you are running through Valgrind is exactly the one you posted in your question, it clearly doesn’t have any memory leaks. In fact, you don’t even use malloc/free yourself! It looks to me like these are spurious errors / false positives that Valgrind detects on OS X (only!), similar to what happened … Read more

Why does valgrind say basic SDL program is leaking memory?

Even for basic OpenGL “hello world” program without the full SDL, Valgrind gives me similar warnings deep inside the OpenGL libraries. It’s peculiar, but I’ve assumed The library implementors know what they’re doing (probably preallocating some small static buffers they never bother to free), Even if they don’t, it’s a one-time leak that’ll be reclaimed … Read more

valgrind memory leak errors when using pthread_create

A thread’s resources are not immediately released at termination, unless the thread was created with the detach state attribute set to PTHREAD_CREATE_DETACHED, or if pthread_detach is called for its pthread_t. An undetached thread will remain terminated state until its identifier is passed to pthread_join or pthread_detach. To sum it up, you have three options: create … Read more

How can I use valgrind with Python C++ extensions?

Yes, you can use valgrind with Python. You just need to use the valgrind suppression file provided by the Python developers, so you don’t get a bunch of false positives due to Python’s custom memory allocation/reallocation functions. The valgrind suppression file can be found here: http://svn.python.org/projects/python/trunk/Misc/valgrind-python.supp IMPORTANT: You need to uncomment the lines for PyObject_Free … Read more

Is it possible to make valgrind ignore certain libraries?

Assuming you are running the memcheck tool and you want to ignore Leak errors in libcrypto only, you could put a suppression like: { ignore_libcrypto_conditional_jump_errors Memcheck:Leak … obj:*/libcrypto.so.* } … into a file and pass it to valgrind with –suppressions=*FILENAME*. To ignore Leak errors in all shared libraries under any lib directory (/lib, /lib64, /usr/lib, … Read more