This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tracing malloc/free call


On Jan 16 18:33, Marco Atzeri wrote:
> 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

Hopefully not your last :)  Feel free to ask on the devs list if you
have questions about the code.

> >>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

I'm glad it works for you, too.

Btw., did you see my PM?


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgpkVo1fqfKrH.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]