Bug 302800 - valgrind using the system allocator instead of jemalloc in operator new
Summary: valgrind using the system allocator instead of jemalloc in operator new
Status: RESOLVED DUPLICATE of bug 219156
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-30 14:52 UTC by egmkang wang
Modified: 2012-07-06 21:11 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description egmkang wang 2012-06-30 14:52:17 UTC
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?
Comment 1 Julian Seward 2012-07-05 13:15:29 UTC
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 ..
Comment 2 Philippe Waroquiers 2012-07-05 17:56:32 UTC
(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.
Comment 3 egmkang wang 2012-07-06 04:59:40 UTC
Thanks very much.
I should wait for valgrind 3.8, if i want to use jemalloc?
Comment 4 Philippe Waroquiers 2012-07-06 21:10:30 UTC
(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
Comment 5 Philippe Waroquiers 2012-07-06 21:11:23 UTC

*** This bug has been marked as a duplicate of bug 219156 ***