From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24694 invoked by alias); 22 Aug 2003 20:48:27 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24686 invoked from network); 22 Aug 2003 20:48:26 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 22 Aug 2003 20:48:26 -0000 Received: from drow by nevyn.them.org with local (Exim 4.20 #1 (Debian)) id 19qIpe-0002zA-9O for ; Fri, 22 Aug 2003 16:48:26 -0400 Date: Fri, 22 Aug 2003 20:48:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Subject: [commit/6.0?] Sanity check in baseclass_offset Message-ID: <20030822204825.GA11440@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i X-SW-Source: 2003-08/txt/msg00405.txt.bz2 If we don't have, for whatever reason, debugging information for a base class, TYPE_VPTR_FIELDNO may be -1. TYPE_FIELDS may also be NULL. When we access 0[-1], we segfault. This patch conditionalizes the sanity check with another sanity check. OK to move this onto the 6.0 branch, given schedule? Checked into HEAD, no regressions. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2003-08-22 Daniel Jacobowitz * gnu-v3-abi.c (gnuv3_baseclass_offset): Check whether TYPE_VPTR_FIELDNO is valid. --- gdb-6.0/gdb/gnu-v3-abi.c.orig 2003-08-22 10:51:25.000000000 -0400 +++ gdb-6.0/gdb/gnu-v3-abi.c 2003-08-22 10:53:13.000000000 -0400 @@ -412,10 +412,15 @@ gnuv3_baseclass_offset (struct type *typ v3 C++ ABI Section 2.4.I.2.b. Fortunately the ABI guarantees that the vtable pointer will be located at the beginning of the object, so we can bypass the casting. Verify that the TYPE_VPTR_FIELDNO is in fact at the - start of whichever baseclass it resides in, as a sanity measure. */ + start of whichever baseclass it resides in, as a sanity measure - iff + we have debugging information for that baseclass. */ vbasetype = TYPE_VPTR_BASETYPE (type); - if (TYPE_FIELD_BITPOS (vbasetype, TYPE_VPTR_FIELDNO (vbasetype)) != 0) + if (TYPE_VPTR_FIELDNO (vbasetype) < 0) + fill_in_vptr_fieldno (vbasetype); + + if (TYPE_VPTR_FIELDNO (vbasetype) >= 0 + && TYPE_FIELD_BITPOS (vbasetype, TYPE_VPTR_FIELDNO (vbasetype)) != 0) error ("Illegal vptr offset in class %s", TYPE_NAME (vbasetype) ? TYPE_NAME (vbasetype) : "");