[haiku-bugs] Re: [Haiku] #5495: Debugger can run into endless loop from within DwarfTypeFactory::CreateType ()

  • From: "anevilyak" <trac@xxxxxxxxxxxx>
  • Date: Wed, 29 Jun 2011 01:59:45 -0000

#5495: Debugger can run into endless loop from within 
DwarfTypeFactory::CreateType
()
-------------------------------------+----------------------------
   Reporter:  stippi                 |      Owner:  anevilyak
       Type:  bug                    |     Status:  in-progress
   Priority:  normal                 |  Milestone:  R1
  Component:  Applications/Debugger  |    Version:  R1/Development
 Resolution:                         |   Keywords:
 Blocked By:                         |   Blocking:  7756
Has a Patch:  0                      |   Platform:  All
-------------------------------------+----------------------------
Changes (by anevilyak):

 * status:  assigned => in-progress
 * cc: bonefish (added)


Comment:

 The problem turns out to be that Debugger wasn't correctly handling
 typedefs for opaque types where the name of the type and the name of the
 typedef were the same, e.g.

 {{{#!c++
 typedef struct structname structname;
 }}}

 When resolving the base type of the typedef, it would correctly find the
 struct, but when creating the type object for that, it would try to look
 up an existing type by the name only, and would find the typedef again,
 leading into an endless recursion repeating that process.

 Attaching a patch which fixes the issue by adding a parameter to
 GlobalTypeLookup::GetType() so we can match by both name and expected
 entry type. This fixes the problem since the typedef is then skipped.
 Since in this case there is no actual definition for the struct in
 question, we consequently fall back to _CreateTypeInternal(), which in
 turn creates a compound type with no bases/members for it, which is what
 we want. The only question is the type of the parameter being passed to
 GlobalTypeLookup, since this should be independent of the underlying debug
 format. Ingo, should we make that a void* in order to accomodate
 potentially more complex types in other formats? For DWARF an int32 is
 sufficient since the tags are simple integers, but I don't know if that's
 the case for the debug formats used with PECOFF and other binary formats.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/5495#comment:7>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: