codes like this: #include <stdlib.h> int main() { int *p = new int(); free(p); return 0; } when i using system's alloctor,it works well.and i got a mismatched warning. but when i using jemalloc, it will abort. when i added a global operator new in it,it will work.but the mismatched free is gone,that should be there. why?
If you want to use malloc/free in a different shared object from libc.so, you can do that, but you need to use --soname-synonyms= to tell Memcheck this. I think PhilippeW will know more ..
(In reply to comment #1) > If you want to use malloc/free in a different shared object from libc.so, > you can > do that, but you need to use --soname-synonyms= to tell Memcheck this. > I think PhilippeW will know more .. Effectively, if you want to detect errors when using jemalloc, you have to ensure that the jemalloc calls are intercepted. The new 3.8.0 --soname-synonyms= allows to do that. The reason why the code crashes when using jemalloc is (I guess) due to the mixture of (partial) interception by Valgrind, and so doing incompatible calls to alloc/free. --soname-synonyms= should allow the above to be covered properly by Valgrind.
Thanks very much. I should wait for valgrind 3.8, if i want to use jemalloc?
(In reply to comment #3) > Thanks very much. > I should wait for valgrind 3.8, if i want to use jemalloc? Effectively, --soname-synonyms is only supported from 3.8.0 onwards, which is not yet released. If you want, you can however get the current SVN version, and test with jemalloc. (the tests I did were either with static linking or with tcmalloc). To get and compile the current SVN version, see http://www.valgrind.org/downloads/repository.html
*** This bug has been marked as a duplicate of bug 219156 ***