This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFA/gas] stabs.c (stabs_generate_asm_file): Free malloced 'dir'.
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: Michael Snyder <msnyder at vmware dot com>
- Cc: binutils at sourceware dot org, rth at redhat dot com
- Date: Thu, 10 Mar 2011 09:31:50 -0800 (PST)
- Subject: Re: [RFA/gas] stabs.c (stabs_generate_asm_file): Free malloced 'dir'.
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