This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13342] New: insufficient memory is fetched from theinferior for partially destroyed C++ objects


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]