|
From: Philippe W. <phi...@sk...> - 2015-04-01 22:57:12
|
On Thu, 2015-04-02 at 00:41 +0200, Julian Seward wrote:
> On 01/04/15 21:25, Philippe Waroquiers wrote:
> > On Tue, 2015-03-31 at 15:28 -0300, Andres Tiraboschi wrote:
> >> But if you want to replace functions from pthread like helgrind and
> >> drd do you have to replace the client malloc/free
> >> I don't know why.
> > To my knowledge, there is no need to replace malloc/free to have
> > helgrind or drd working.
>
> Well, I think it is important, because both tools need to know when
> memory is freed and later re-allocated. Without that, they would report
> false races on memory that has been freed and then reallocated to a
> different thread. In effect the freeing marks the memory as un-tracked
> and causes them to "forget" what they know about it.
>
> Also, it helps generate better error messages. With malloc/free
> intercepting, we can generate address descriptions like "address X
> is N bytes inside a block of size M allocated at ..".
Yes for sure, for these tools to properly detect errors,
malloc replacement is highly recommended.
But the question discussed initially is: is it *mandatory*
to replace malloc/free/... if you want to wrap pthread functions
and not have a segmentation violation ?
I answered no, and "proved that" by telling that helgrind does
not crash when e.g. using it with tcmalloc and not using
--soname-synonyms=...
In such a case, malloc/tcmalloc is *not* replaced, but still
helgrind (or drd) will not crash.
So, in summary, the discussion status is:
1. it is not mandatory to replace malloc if you want to wrap
a pthread function
2. the segmentation violation encountered by Andres in
his small trial to wrap pthread is IMO not caused
by not replacing malloc. It is just that replacing malloc
bypasses the segv I believe.
Philippe
|