Created attachment 39138 [details] A patch that add the necessary interceptors to Coregrind (applies to r10880) It would be nice if Valgrind handled custom (i.e. non-libc) allocation/deallocation functions, like those in TCMalloc. The proposed patch adds the support for custom malloc/free/new/delete methods, allowing Valgrind to find memory problems in the programs that use custom allocation libraries. The patch also fixes a problem with Bash induced by intercepting custom malloc/free functions. Bash has sh_malloc/sh_free as well as malloc/free, and those are sometimes used inconsistently (e.g. sh_free after malloc). To fix this, we should intercept sh_malloc/sh_free as well. The third type of interceptors added by the patch is for Python's PyObject_Malloc, PyObject_Free and PyObject_Realloc. Currently Memcheck reports many errors in these functions. To deal with them, the developers usually make suppressions and even build custom Python packages without PyObject_*, whereas the correct solution is to intercept these functions inside Valgrind.
Created attachment 69443 [details] redirects for tcmalloc (gperftools) This patch (derived from patch 1) allows memcheck to intercept malloc/free/... in the various tcmalloc shared libraries (libtcmalloc.so, libtcmalloc_minimal.so, ...) Reg Tested on deb6/amd64. Checked that it finds leaks with libtcmalloc on f12/x86 and deb6/amd64.
Created attachment 70904 [details] clo option to allow replacement for an alternate shared lib or for a statically linked lib E.g. to have memcheck&massif properly working with tcmalloc; give: --soname-syns=somalloc=*tcmalloc* for a statically linked library; use -soname-syns=somalloc=NONE
Fixed in revision 12559. (main difference compared to previous patch is --soname-syns renamed to --soname-synonyms)
*** Bug 302800 has been marked as a duplicate of this bug. ***
*** Bug 304346 has been marked as a duplicate of this bug. ***