This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[COMMITTED PATCH] Fix infinite loop in update_enumeration_type_from_children
- From: Doug Evans <dje at google dot com>
- To: Daniel Colascione <dancol at dancol dot org>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Thu, 13 Nov 2014 16:39:49 -0800
- Subject: [COMMITTED PATCH] Fix infinite loop in update_enumeration_type_from_children
- Authentication-results: sourceware.org; auth=none
- References: <543300A0 dot 50705 at dancol dot org> <CADPb22QvBYWaYMGwpUEwk5K1AbRKqQBgRGK8vrgigR2VTzifhA at mail dot gmail dot com> <545FE524 dot 5070607 at dancol dot org> <CADPb22QvmoHK_8B47EkBy6Y1BAa6ea71NcrqLFvBSroun-GHwA at mail dot gmail dot com>
Doug Evans writes:
> On Sun, Nov 9, 2014 at 2:05 PM, Daniel Colascione <dancol@dancol.org> wrote:
> > On 10/08/2014 06:58 AM, Doug Evans wrote:
> >> Changing the loop to a for loop is another way to go, and arguably preferable.
> >
> > Either way, it looks like this bug is unfixed in master. Now that I have
> > papers, can this patch (or an equivalent for-loop version) be committed?
>
> Hi.
> I kinda like the for-loop version better.
> I'll get that checked in today.
Committed.
2014-11-13 Doug Evans <dje@google.com>
* dwarf2read.c (update_enumeration_type_from_children): Avoid
infinite loop.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ce37adf..1250bc7 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -13231,7 +13231,7 @@ update_enumeration_type_from_children (struct die_info *die,
struct dwarf2_cu *cu)
{
struct obstack obstack;
- struct die_info *child_die = die->child;
+ struct die_info *child_die;
int unsigned_enum = 1;
int flag_enum = 1;
ULONGEST mask = 0;
@@ -13240,13 +13240,16 @@ update_enumeration_type_from_children (struct die_info *die,
obstack_init (&obstack);
old_chain = make_cleanup_obstack_free (&obstack);
- while (child_die != NULL && child_die->tag)
+ for (child_die = die->child;
+ child_die != NULL && child_die->tag;
+ child_die = sibling_die (child_die))
{
struct attribute *attr;
LONGEST value;
const gdb_byte *bytes;
struct dwarf2_locexpr_baton *baton;
const char *name;
+
if (child_die->tag != DW_TAG_enumerator)
continue;
@@ -13274,7 +13277,6 @@ update_enumeration_type_from_children (struct die_info *die,
a flag type, no need to look at the rest of the enumerates. */
if (!unsigned_enum && !flag_enum)
break;
- child_die = sibling_die (child_die);
}
if (unsigned_enum)