This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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: Avoid obstack_free in cp-namespace.c


Daniel Jacobowitz writes:
 > 
 > [For the curious I've audited the remaining uses of obstack_free in GDB. 
 > The ones in jv-lang.c and stabsread.c are suspicious but seem to be OK, and
 > the rest are fine except for this one - they release whole obstacks.]

I already did this in my cleanups. For the curious, you might as well
explain the whole story. The obstack_free function takes a pointer to
where in the stack it must start the deletion from (much like the
cleanup chains have a pointer to where to start the cleanups). The
obstack_free's in jv-lang.c and stabsread.c are done after some local
stuff is allocated to the obstack. Only the local stuff is deleted
from the obstack. Of course this assumes that nothing between the
obstack_alloc and the obstack_free allocates anything else on the same
obstack. For this reason other files use temporary obstacks. Maybe
jv-lang.c and stabsread.c could do the same. This one had the same
assumption.

Releasing the whole obstack is not safe per se. It is safe only under
the condition that we know the obstacks memory is no longer
needed. In GDB we blow away the obstacks only when we get rid of the
whole objfile(s). 

elena


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