[RFA/gas] stabs.c (stabs_generate_asm_file): Free malloced 'dir'.

Steve Ellcey sje@cup.hp.com
Thu Mar 10 17:32:00 GMT 2011


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



More information about the Binutils mailing list