Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/RFC/dwarf] detect 0xffffffff size attribute values
@ 2008-06-19  3:58 Joel Brobecker
  2008-06-19 13:56 ` Jan Kratochvil
  2008-06-26 13:45 ` Daniel Jacobowitz
  0 siblings, 2 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-06-19  3:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Kratochvil

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

Hello,

This an attempt to guard against a compiler bug:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35998

I know that Olivier and Eric told me that they committed some changes
in gigi that should fix some of the problems, but I don't know if this
one is already fixed on not. If someone does a build from HEAD could
tell me, that'd be great.

In any case, to help handling older versions of the compiler,
I propose we install a guard against -1 size attributes, which
get encoded as 0xffffffff.  When we detect this size attribute
value, we pretend we actually read 0.  This avoids attempting
to make a huge memory allocation when trying to create a value
of the associated type.

Jan, could you check whether this fixes the problem you saw?

2008-06-19  Joel Brobecker  <brobecker@adacore.com>

        * dwarf2read.c (read_attribute_value): Treat size attribute
        values of 0xffffffff as if the attribute value was zero.

Tested on x86-linux (both the standard regression testsuite and
the AdaCore regression testsuite). No regression.

What do you think? I know Daniel said during one of our conversations
that the idea itself is reasonable, but does the implementation look
OK to you?

Thanks,
-- 
Joel

[-- Attachment #2: dwarf2read.c.diff --]
[-- Type: text/plain, Size: 854 bytes --]

Index: dwarf2read.c
===================================================================
--- dwarf2read.c	(revision 132585)
+++ dwarf2read.c	(working copy)
@@ -6487,6 +6487,18 @@ read_attribute_value (struct attribute *
 	     dwarf_form_name (form),
 	     bfd_get_filename (abfd));
     }
+
+  /* We have seen instances where the compiler tried to emit a byte
+     size attribute of -1 which ended up being encoded as an unsigned
+     0xffffffff.  Although 0xffffffff is technically a valid size value,
+     an object of this size seems pretty unlikely so we can relatively
+     safely treat these cases as if the size attribute was invalid and
+     treat them as zero by default.  */
+  if (attr->name == DW_AT_byte_size
+      && form == DW_FORM_data4
+      && DW_UNSND (attr) >= 0xffffffff)
+    DW_UNSND (attr) = 0;
+
   return info_ptr;
 }
 

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

end of thread, other threads:[~2008-06-27 17:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-19  3:58 [RFA/RFC/dwarf] detect 0xffffffff size attribute values Joel Brobecker
2008-06-19 13:56 ` Jan Kratochvil
2008-06-26 13:45 ` Daniel Jacobowitz
2008-06-26 20:11   ` Joel Brobecker
2008-06-26 20:19     ` Daniel Jacobowitz
2008-06-26 23:26       ` Joel Brobecker
2008-06-27  0:15         ` Daniel Jacobowitz
2008-06-27 18:20           ` Joel Brobecker

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