Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit/6.0?] Sanity check in baseclass_offset
@ 2003-08-22 20:48 Daniel Jacobowitz
  2003-08-24 13:58 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-08-22 20:48 UTC (permalink / raw)
  To: gdb-patches

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>");
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [commit/6.0?] Sanity check in baseclass_offset
  2003-08-22 20:48 [commit/6.0?] Sanity check in baseclass_offset Daniel Jacobowitz
@ 2003-08-24 13:58 ` Andrew Cagney
  2003-08-24 16:53   ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2003-08-24 13:58 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

> 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.

I think so.

Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [commit/6.0?] Sanity check in baseclass_offset
  2003-08-24 13:58 ` Andrew Cagney
@ 2003-08-24 16:53   ` Daniel Jacobowitz
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-08-24 16:53 UTC (permalink / raw)
  To: gdb-patches

On Sun, Aug 24, 2003 at 08:29:06AM -0400, Andrew Cagney wrote:
> >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.
> 
> I think so.

Checked in on the branch, thanks.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-08-24 16:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-22 20:48 [commit/6.0?] Sanity check in baseclass_offset Daniel Jacobowitz
2003-08-24 13:58 ` Andrew Cagney
2003-08-24 16:53   ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox