This is the mail archive of the
mailing list for the GDB project.
Re: protection from dangling pointers in dwarf info when .so's go away
On Dec 12, 2007 7:27 PM, Daniel Jacobowitz <firstname.lastname@example.org> wrote:
> On Wed, Dec 12, 2007 at 05:57:58PM -0800, Doug Evans wrote:
> > Is it the case that vptr_basetype for myclass should never have gotten
> > assigned a value pointing into a .so (or any other obstack)?
> Sounds likely to me, but may not be practical.
> > Or is
> > gdb supposed to have cleaned up after itself when the .so data got
> > freed?
> We do this for user variables when their objfile goes away, by
> recursively copying their type. We don't walk types from other
> objfiles looking for pointers, so there really shouldn't be any.
> > Or something else? Any guidance on where the fix should go is
> > appreciated. I suppose an easy solution is to toss out all info, not
> > just for .so's, though that will slow down re-runs.
> No, that's impossible. Remember dlopen and dlclose.
Righto, and thanks.
It seems like check_typedef is aware of the issue:
/* [...] We can't create pointers between
types allocated to different objfiles, since they may
have different lifetimes. [...] */
but fill_in_vptr_fieldno is not:
fill_in_vptr_fieldno (struct type *type)
if (TYPE_VPTR_FIELDNO (type) < 0)
/* We must start at zero in case the first (and only) baseclass
is virtual (and hence we cannot share the table pointer). */
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
struct type *baseclass = check_typedef (TYPE_BASECLASS (type,
if (TYPE_VPTR_FIELDNO (baseclass) >= 0)
TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (baseclass);
TYPE_VPTR_BASETYPE (type) = TYPE_VPTR_BASETYPE (baseclass);
What happens if TYPE_OBJFILE (type) != TYPE_OBJFILE
(TYPE_VPTR_BASETYPE (baseclass)) ?