[lttng-dev] [PATCH lttng-ust] Add trace support for calloc and realloc.

Alexander Monakov amonakov at ispras.ru
Thu Aug 1 13:57:28 EDT 2013


On Thu, Aug 1, 2013 at 9:28 PM, Stefan Seefeld
<stefan_seefeld at mentor.com> wrote:
> I don't think any of this works. The ultimate problem is the one Jérémie
> reported initially: dlsym will eventually call free() on the memory
> calloc() returned, so my calloc fallback needs to return something that
> can actually be freed.

I pointed out how free() will be safe specifically:

>> dlsym stores pointer to calloc'ed buffer, overwriting the pointer to mmap'ed
>> buffer, completing initialization for the second time and making the
>> subsequent free() safe.

Besides, you're intercepting free() in your LD_PRELOAD module as well,
so you can just catch attempts to free your mmap'ed buffers there and
munmap them safely.

Alexander



More information about the lttng-dev mailing list