* [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
* Re: [RFA/RFC/dwarf] detect 0xffffffff size attribute values
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
1 sibling, 0 replies; 8+ messages in thread
From: Jan Kratochvil @ 2008-06-19 13:56 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Thu, 19 Jun 2008 05:32:41 +0200, Joel Brobecker wrote:
...
> Jan, could you check whether this fixes the problem you saw?
Yes, it works perfectly for GDB CVS HEAD.
GCC DWARF (not GNAT) fix was posted at:
http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01857.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/RFC/dwarf] detect 0xffffffff size attribute values
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
1 sibling, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2008-06-26 13:45 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Jan Kratochvil
On Wed, Jun 18, 2008 at 11:32:41PM -0400, Joel Brobecker wrote:
> 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.
OK. A complaint when this happens wouldn't be a bad thing, either.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/RFC/dwarf] detect 0xffffffff size attribute values
2008-06-26 13:45 ` Daniel Jacobowitz
@ 2008-06-26 20:11 ` Joel Brobecker
2008-06-26 20:19 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2008-06-26 20:11 UTC (permalink / raw)
To: gdb-patches, Jan Kratochvil
[-- Attachment #1: Type: text/plain, Size: 1080 bytes --]
Hi Daniel,
> > 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.
>
> OK. A complaint when this happens wouldn't be a bad thing, either.
Thanks for the review. I am not 100% sure about the complaint, because
I presume that this issue happens on a routine basis whenever record
types (the equivalent of structs) whose size is dynamic are used.
If they are frequent, my concern is that the complaint mechanism would
be shut down by several repetitions of the same complaint before giving
other complaints a chance to print their message? Perhaps we could
decide to define a new complaint category, instead of using the symtab
category? In the meantime, I checked the initial patch in, and started
testing the following patch:
2008-06-26 Joel Brobecker <brobecker@adacore.com>
* dwarf2read.c (read_attribute_value): Issue a complaint when
adjusting size attribute values of 0xffffffff as zero.
WDYT?
--
Joel
[-- Attachment #2: dwarf-complaint.diff --]
[-- Type: text/plain, Size: 705 bytes --]
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.266
diff -u -p -r1.266 dwarf2read.c
--- dwarf2read.c 26 Jun 2008 19:08:10 -0000 1.266
+++ dwarf2read.c 26 Jun 2008 19:25:09 -0000
@@ -6244,7 +6244,13 @@ read_attribute_value (struct attribute *
if (attr->name == DW_AT_byte_size
&& form == DW_FORM_data4
&& DW_UNSND (attr) >= 0xffffffff)
- DW_UNSND (attr) = 0;
+ {
+ complaint
+ (&symfile_complaints,
+ _("Suspicious DW_AT_byte_size value treated as zero instead of %lx"),
+ DW_UNSND (attr));
+ DW_UNSND (attr) = 0;
+ }
return info_ptr;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/RFC/dwarf] detect 0xffffffff size attribute values
2008-06-26 20:11 ` Joel Brobecker
@ 2008-06-26 20:19 ` Daniel Jacobowitz
2008-06-26 23:26 ` Joel Brobecker
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2008-06-26 20:19 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Jan Kratochvil
On Thu, Jun 26, 2008 at 03:34:19PM -0400, Joel Brobecker wrote:
> 2008-06-26 Joel Brobecker <brobecker@adacore.com>
>
> * dwarf2read.c (read_attribute_value): Issue a complaint when
> adjusting size attribute values of 0xffffffff as zero.
>
> WDYT?
If it's any work, it's not worth spending time on, IMO. No one looks
at the complaints except us.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/RFC/dwarf] detect 0xffffffff size attribute values
2008-06-26 20:19 ` Daniel Jacobowitz
@ 2008-06-26 23:26 ` Joel Brobecker
2008-06-27 0:15 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2008-06-26 23:26 UTC (permalink / raw)
To: gdb-patches, Jan Kratochvil
> > 2008-06-26 Joel Brobecker <brobecker@adacore.com>
> >
> > * dwarf2read.c (read_attribute_value): Issue a complaint when
> > adjusting size attribute values of 0xffffffff as zero.
> >
> > WDYT?
>
> If it's any work, it's not worth spending time on, IMO. No one looks
> at the complaints except us.
If it's just us, then I suggest we commit the complaint as is. We can
always increase the threshold when necessary. I have scripts that
automate the testing and the results came back clean.
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/RFC/dwarf] detect 0xffffffff size attribute values
2008-06-26 23:26 ` Joel Brobecker
@ 2008-06-27 0:15 ` Daniel Jacobowitz
2008-06-27 18:20 ` Joel Brobecker
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2008-06-27 0:15 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Jan Kratochvil
On Thu, Jun 26, 2008 at 04:11:27PM -0400, Joel Brobecker wrote:
> If it's just us, then I suggest we commit the complaint as is. We can
> always increase the threshold when necessary. I have scripts that
> automate the testing and the results came back clean.
No objection.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/RFC/dwarf] detect 0xffffffff size attribute values
2008-06-27 0:15 ` Daniel Jacobowitz
@ 2008-06-27 18:20 ` Joel Brobecker
0 siblings, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-06-27 18:20 UTC (permalink / raw)
To: gdb-patches, Jan Kratochvil
> > If it's just us, then I suggest we commit the complaint as is. We can
> > always increase the threshold when necessary. I have scripts that
> > automate the testing and the results came back clean.
>
> No objection.
Cool! Now checked in.
--
Joel
^ 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