tracing malloc/free call

Marco Atzeri marco.atzeri@gmail.com
Fri Jan 16 17:33:00 GMT 2015


On 1/16/2015 5:22 PM, Corinna Vinschen wrote:
> On Jan 16 16:44, Corinna Vinschen wrote:
>> On Jan 16 15:23, Marco Atzeri wrote:
>>> Attached patch that allows tracking of original caller,
>>> for the 4 memory allocation calls.
>>
>> Thanks for the patch, but it won't work nicely either this way.  The
>> problem is that, in theory, the code has to differ between internal and
>> external callers.  Internal callers (that is, Cygwin functions itself)
>> don't hop into the function via _sigfe/_sigbe.  Thus the output for
>> internal callers of malloc/free is now wrong with your patch.

I missed that point. ;-)
First time I look at these inside details of cygwin

>> The solution for this problem would be a test which checks if the return
>> address is the _sigbe function and if so, returns *(_my_tls.stackptr-1),
>> otherwise __builtin_return_address(0).  However, the symbol _sigbe is
>> not exported since, so far, it was only used inside _sigfe.  This needs
>> a bit of tweaking.  I'll have a look.
>
> I applied a patch to print the right caller address.  I created a new
> macro caller_return_address() for reuse, should we have a desire to
> print the caller address in other parts of the code.
>
> I'm going to create a snapshot with this change.  Please give it
> a try.

It works like charm.
Much more easy to find misalignment between
malloc/calloc/realloc and free calls

> Thanks,
> Corinna
>



More information about the Cygwin-patches mailing list