This is the mail archive of the
mailing list for the glibc project.
Re: mtrace: Alloc duplicate
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Martin Brandenburg <martin at omnibond dot com>
- Cc: libc-help at sourceware dot org
- Date: Thu, 15 May 2014 17:58:47 +0200
- Subject: Re: mtrace: Alloc duplicate
- Authentication-results: sourceware.org; auth=none
- References: <CA+D=wkiKyy8=u2pnggAnUUtZq06WBoSqwcz7zbYNj-X7Lpw1Sg at mail dot gmail dot com>
On Thu, May 15, 2014 at 10:45:39AM -0400, Martin Brandenburg wrote:
> I am using mtrace to debug memory leaks in a program. I am getting
> output of the following form from mtrace:
> + 0x00000000024097d0 Alloc 1219709 duplicate: 0x4b372b
> Reading the raw log it looks like the same pointer is allocated twice.
> The program is multi-threaded, so I've thought about that as a reason.
> There are some notes that mtrace(3) uses malloc_hook(3) and that
> malloc_hook does not work well in a multithreaded environment. Is this
> the cause of the problem? Does this output indicate a bug in my program
> or just a problem with mtrace in multithreaded systems? The rest of the
> output is still useful.
It is probably problem in mtrace, it should not be used in multithread
Most likely scenario is that thread A allocated and freed a pointer but
was suspended before it flushed output containing free. Then thread B
allocated same pointer flushed that allocation before thread A could
flush its buffer.