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

Stefan Seefeld stefan_seefeld at mentor.com
Thu Aug 1 13:28:56 EDT 2013


On 08/01/2013 01:19 PM, Alexander Monakov wrote:
> 
> 
> On Thu, 1 Aug 2013, Alexander Monakov wrote:
> 
>> Okay, one more hack :)
>>
>> Recurse *once* by calling dlsym inside your calloc, and terminate recursion by
>> obtaining memory from mmap.
> 
> Correction: since there's no guarantee that the very first calloc invocation
> will happen from inside dlsym, you have to recurse twice, not once, to be sure
> that there are two dlsyms on the stack.

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.

	Stefan

-- 
Stefan Seefeld
CodeSourcery / Mentor Graphics
http://www.mentor.com/embedded-software/



More information about the lttng-dev mailing list