public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13342] New: insufficient memory is fetched from the inferior for partially destroyed C++ objects
@ 2011-10-25 14:54 eric+sourceware at vangyzen dot net
  2011-10-25 15:16 ` [Bug c++/13342] " eric+sourceware at vangyzen dot net
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: eric+sourceware at vangyzen dot net @ 2011-10-25 14:54 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13342

             Bug #: 13342
           Summary: insufficient memory is fetched from the inferior for
                    partially destroyed C++ objects
           Product: gdb
           Version: 7.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: eric+sourceware@vangyzen.net
    Classification: Unclassified


Created attachment 6033
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6033
proposed patch

When GDB prints the contents of a C++ object during that object's destructor
call-chain, GDB does not fetch enough memory from the inferior, so it shows
uninitialized data for some members (those added by the class(es) whose
destructors have already run).

For example, consider the destruction of an Apple, which is a subclass of
Fruit.  When the Apple destructor completes, the Fruit destructor is called. 
During the Fruit destructor, we ask GDB to "print *this".  The object's RTTI
data say it's a Fruit (no longer an Apple).  In valops.c:value_full_object(),
GDB takes the "if (full)" path and sets the value's enclosing type to Fruit. 
Thus, GDB later fetches only sizeof(Fruit) bytes from the inferior, although it
should fetch sizeof(Apple).  This, "print" shows uninitialized data for the
members of "this" that were added in the Apple class.

Changing the value's enclosing type is helpful when the enclosing type is
larger, such as during an operation on a Fruit pointer that is really pointing
to an Apple.  However, it's harmful in the opposite case of an Apple pointer
pointing to [that which is currently] a Fruit.  Perhaps we should change the
enclosing type iff the real (RTTI) type is no smaller than the current
enclosing type?  I am no GDB expert, so there is probably a more correct fix.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2011-11-09 20:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 14:54 [Bug c++/13342] New: insufficient memory is fetched from the inferior for partially destroyed C++ objects eric+sourceware at vangyzen dot net
2011-10-25 15:16 ` [Bug c++/13342] " eric+sourceware at vangyzen dot net
2011-10-25 15:16 ` eric+sourceware at vangyzen dot net
2011-10-25 15:17 ` eric+sourceware at vangyzen dot net
2011-11-02 14:53 ` tromey at redhat dot com
2011-11-02 15:22 ` eric+sourceware at vangyzen dot net
2011-11-03 16:57 ` tromey at redhat dot com
2011-11-03 19:17 ` eric+sourceware at vangyzen dot net
2011-11-08 14:17 ` peter.schauer at mytum dot de
2011-11-08 15:51 ` tromey at redhat dot com
2011-11-08 16:39 ` eric+sourceware at vangyzen dot net
2011-11-09 19:24 ` tromey at redhat dot com
2011-11-09 19:50 ` cvs-commit at gcc dot gnu.org
2011-11-09 19:53 ` tromey at redhat dot com
2011-11-09 20:38 ` eric+sourceware at vangyzen dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).