This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [RFA/gas] stabs.c (stabs_generate_asm_file): Free malloced 'dir'.


Steve Ellcey wrote:
Michael,

I believe this patch is causing the GNU assembler to abort on my
ia64-hp-hpux11.23 platform.  When I remove the xfree calls you added the
abort goes away.  I don't know if anyone else is seeing this but here is
what I think is happening:  The xfree calls are freeing the pointer
returned from remap_debug_filename and remap_debug_filename may allocate
new memory or it may just return the pointer that was passed in to it.
In some cases the pointer passed in to remap_debug_filename comes from a
getpwd call.  Now getpwd calls getcwd and keeps the return value of
getcwd in a static pointer for reuse.  I think we are calling getpwd
once, setting the static variable, using that pointer in a
remap_debug_filename call (which returns the same pointer) and then
freeing that allocated space.  But that doesn't change the value of the
static pointer in getpwd, so the next time we call getpwd we get a
pointer to freed memory and try to use (and then free) that already
freed memory.   I think that is where the abort is happening.

Steve Ellcey
sje@cup.hp.com

Thanks for the excellent analysis.


However, I never checked in the change you are referring to.
Are you sure you're not thinking of the similar change that I
checked in to dwarf2dbg.c?


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