This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit/6.0?] Sanity check in baseclass_offset
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 22 Aug 2003 16:48:26 -0400
- Subject: [commit/6.0?] Sanity check in baseclass_offset
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 <drow@mvista.com>
* 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) : "<unknown>");