Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fix infinite loop in update_enumeration_type_from_children
@ 2014-10-06 20:50 Daniel Colascione
  2014-10-07 18:07 ` Pedro Alves
  2014-10-08  5:58 ` Doug Evans
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Colascione @ 2014-10-06 20:50 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 738 bytes --]

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)


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: Fix infinite loop in update_enumeration_type_from_children
  2014-10-06 20:50 Fix infinite loop in update_enumeration_type_from_children Daniel Colascione
@ 2014-10-07 18:07 ` Pedro Alves
  2014-10-08  5:58 ` Doug Evans
  1 sibling, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2014-10-07 18:07 UTC (permalink / raw)
  To: Daniel Colascione, gdb-patches

Please see the contribution check list:

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

Thanks,
Pedro Alves


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

* Re: Fix infinite loop in update_enumeration_type_from_children
  2014-10-06 20:50 Fix infinite loop in update_enumeration_type_from_children Daniel Colascione
  2014-10-07 18:07 ` Pedro Alves
@ 2014-10-08  5:58 ` Doug Evans
  2014-11-09 22:05   ` Daniel Colascione
  1 sibling, 1 reply; 6+ messages in thread
From: Doug Evans @ 2014-10-08  5:58 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: gdb-patches

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.


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

* Re: Fix infinite loop in update_enumeration_type_from_children
  2014-10-08  5:58 ` Doug Evans
@ 2014-11-09 22:05   ` Daniel Colascione
  2014-11-12 15:52     ` Doug Evans
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Colascione @ 2014-11-09 22:05 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 277 bytes --]

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?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: Fix infinite loop in update_enumeration_type_from_children
  2014-11-09 22:05   ` Daniel Colascione
@ 2014-11-12 15:52     ` Doug Evans
  2014-11-14  0:39       ` [COMMITTED PATCH] " Doug Evans
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Evans @ 2014-11-12 15:52 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: gdb-patches

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.


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

* [COMMITTED PATCH] Fix infinite loop in update_enumeration_type_from_children
  2014-11-12 15:52     ` Doug Evans
@ 2014-11-14  0:39       ` Doug Evans
  0 siblings, 0 replies; 6+ messages in thread
From: Doug Evans @ 2014-11-14  0:39 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: gdb-patches

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)


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

end of thread, other threads:[~2014-11-14  0:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 20:50 Fix infinite loop in update_enumeration_type_from_children Daniel Colascione
2014-10-07 18:07 ` Pedro Alves
2014-10-08  5:58 ` Doug Evans
2014-11-09 22:05   ` Daniel Colascione
2014-11-12 15:52     ` Doug Evans
2014-11-14  0:39       ` [COMMITTED PATCH] " Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox