From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31749 invoked by alias); 13 Dec 2007 08:16:44 -0000 Received: (qmail 31737 invoked by uid 22791); 13 Dec 2007 08:16:43 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 13 Dec 2007 08:16:39 +0000 Received: from zps18.corp.google.com (zps18.corp.google.com [172.25.146.18]) by smtp-out.google.com with ESMTP id lBD8Gb1W005019 for ; Thu, 13 Dec 2007 00:16:37 -0800 Received: from wa-out-1112.google.com (wafm38.prod.google.com [10.114.189.38]) by zps18.corp.google.com with ESMTP id lBD8FGKU014483 for ; Thu, 13 Dec 2007 00:16:37 -0800 Received: by wa-out-1112.google.com with SMTP id m38so984202waf.5 for ; Thu, 13 Dec 2007 00:16:36 -0800 (PST) Received: by 10.114.157.1 with SMTP id f1mr301441wae.13.1197533796110; Thu, 13 Dec 2007 00:16:36 -0800 (PST) Received: by 10.115.107.7 with HTTP; Thu, 13 Dec 2007 00:16:36 -0800 (PST) Message-ID: Date: Thu, 13 Dec 2007 08:16:00 -0000 From: "Doug Evans" To: gdb@sourceware.org Subject: Re: protection from dangling pointers in dwarf info when .so's go away In-Reply-To: <20071213032724.GA25868@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071213032724.GA25868@caradoc.them.org> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00086.txt.bz2 On Dec 12, 2007 7:27 PM, Daniel Jacobowitz 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: void fill_in_vptr_fieldno (struct type *type) { CHECK_TYPEDEF (type); if (TYPE_VPTR_FIELDNO (type) < 0) { int i; /* 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, i)); fill_in_vptr_fieldno (baseclass); if (TYPE_VPTR_FIELDNO (baseclass) >= 0) { TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (baseclass); TYPE_VPTR_BASETYPE (type) = TYPE_VPTR_BASETYPE (baseclass); break; } } } } What happens if TYPE_OBJFILE (type) != TYPE_OBJFILE (TYPE_VPTR_BASETYPE (baseclass)) ?