This is the mail archive of the binutils@sources.redhat.com 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: [PATCH] ia64 unwind directive semantics


On Wed, 2005-02-02 at 06:52, Jan Beulich wrote:
>        hash_delete (md.dynreg_hash, dr->name);
> +      obstack_free (&notes, (void *) dr->name);

I don't believe this is safe.  obstacks are stack based.  When you call
obstack_free, not only does it free dr->name, but also everything newer
than it.  There is no guarantee that everything newer than dr->name is
unused.  This is very unlikely to be the case.  There could have been an
obstack call used for something else (non hash table) in the meantime.

There is also an efficiency issue here, as the right way to free these
string if we could would be with a single obstack_free call, for the
oldest string.  Calling obstack_free on each string means we are freeing
them multiple times, which is probably not good.

This is different than the demand_copy_C_string case, as in that case we
know that there is no other obstack allocation between the
demand_copy_C_string call and the obstack_free.

If we want to be able to free these strings here, then we can't use
obstack to allocate them.

>  	  as_bad ("Attempt to redefine register set `%s'", name);
> +	  obstack_free (&notes, name);

This one is safe, because we know that there are no other allocations on
the notes obstack since this string was allocated.

The rest of the patch looks OK.  This is your ia64-pound patch.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



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