Fix infinite loop in update_enumeration_type_from_children

Message ID 543300A0.50705@dancol.org
State New, archived
Headers

Commit Message

Daniel Colascione Oct. 6, 2014, 8:50 p.m. UTC
  if (name == NULL)
  

Comments

Pedro Alves Oct. 7, 2014, 6:07 p.m. UTC | #1
Please see the contribution check list:

http://sourceware.org/gdb/wiki/ContributionChecklist

Thanks,
Pedro Alves
  
Doug Evans Oct. 8, 2014, 5:58 a.m. UTC | #2
On Mon, Oct 6, 2014 at 4:50 PM, Daniel Colascione <dancol@dancol.org> wrote:
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 9d0ee13..d324b6d 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -13247,12 +13247,16 @@ update_enumeration_type_from_children (struct
> die_info *die,
>        const gdb_byte *bytes;
>        struct dwarf2_locexpr_baton *baton;
>        const char *name;
> -      if (child_die->tag != DW_TAG_enumerator)
> +      if (child_die->tag != DW_TAG_enumerator) {
> +       child_die = sibling_die (child_die);
>         continue;
> +      }
>
>        attr = dwarf2_attr (child_die, DW_AT_const_value, cu);
> -      if (attr == NULL)
> +      if (attr == NULL) {
> +       child_die = sibling_die (child_die);
>         continue;
> +      }
>
>        name = dwarf2_name (child_die, cu);
>        if (name == NULL)
>

Thanks for finding this.

Changing the loop to a for loop is another way to go, and arguably preferable.
  
Daniel Colascione Nov. 9, 2014, 10:05 p.m. UTC | #3
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?
  
Doug Evans Nov. 12, 2014, 3:52 p.m. UTC | #4
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.
  

Patch

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9d0ee13..d324b6d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -13247,12 +13247,16 @@  update_enumeration_type_from_children (struct
die_info *die,
       const gdb_byte *bytes;
       struct dwarf2_locexpr_baton *baton;
       const char *name;
-      if (child_die->tag != DW_TAG_enumerator)
+      if (child_die->tag != DW_TAG_enumerator) {
+	child_die = sibling_die (child_die);
 	continue;
+      }

       attr = dwarf2_attr (child_die, DW_AT_const_value, cu);
-      if (attr == NULL)
+      if (attr == NULL) {
+	child_die = sibling_die (child_die);
 	continue;
+      }

       name = dwarf2_name (child_die, cu);