[dwarf] : PR/47209 Segfault in should_emit_struct_debug

Submitted by Kai Tietz on Jan. 11, 2011, 8:58 p.m.

Details

Message ID AANLkTimEo-nNaXbcpbzAjEWKVSRTnyW17Ruu5jtuXikO@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Jan. 11, 2011, 8:58 p.m.
Hello,

following patch fixes reported segfault at

ChangeLog

2011-01-11  Kai Tietz

          PR debug/47209
          * dwarfout2.c (should_emit_struct_debug): Use TYPE_MAIN_VARIANT
          of type.

Tested for x86_64-pc-linux-gnu and x86_64-pc-mingw32. Ok for apply?

Regards,
Kai

--

Comments

H.J. Lu Jan. 11, 2011, 9:23 p.m.
On Tue, Jan 11, 2011 at 12:58 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> following patch fixes reported segfault at
>
> ChangeLog
>
> 2011-01-11  Kai Tietz
>
>          PR debug/47209
>          * dwarfout2.c (should_emit_struct_debug): Use TYPE_MAIN_VARIANT
>          of type.
>
> Tested for x86_64-pc-linux-gnu and x86_64-pc-mingw32. Ok for apply?
>

You need to add testcases.
Richard Guenther Jan. 12, 2011, 10:04 a.m.
On Tue, Jan 11, 2011 at 9:58 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> following patch fixes reported segfault at
>
> ChangeLog
>
> 2011-01-11  Kai Tietz
>
>          PR debug/47209
>          * dwarfout2.c (should_emit_struct_debug): Use TYPE_MAIN_VARIANT
>          of type.
>
> Tested for x86_64-pc-linux-gnu and x86_64-pc-mingw32. Ok for apply?
>
> Regards,
> Kai
>
> --
>
> Index: dwarf2out.c
> ===================================================================
> --- dwarf2out.c (revision 168679)
> +++ dwarf2out.c (working copy)
> @@ -619,7 +619,7 @@
>   if (criterion == DINFO_STRUCT_FILE_ANY)
>     return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
>
> -  type_decl = TYPE_STUB_DECL (type);
> +  type_decl = TYPE_STUB_DECL(TYPE_MAIN_VARIANT(type));

Why?  That will go to the non-type-decl variant, so it seems wrong.

Richard.

>
>   if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
>     return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
>
Jason Merrill Jan. 12, 2011, 4:17 p.m.
On 01/12/2011 05:04 AM, Richard Guenther wrote:
>> -  type_decl = TYPE_STUB_DECL (type);
>> +  type_decl = TYPE_STUB_DECL(TYPE_MAIN_VARIANT(type));
>
> Why?  That will go to the non-type-decl variant, so it seems wrong.

TYPE_STUB_DECL only makes sense on the primary variant of a struct. 
cv-qualified or typedef variants don't have the stub decl, which is why 
the testcase was crashing.

The patch is OK with the whitespace fix Dave pointed out.

Jason
Kai Tietz Jan. 12, 2011, 5:03 p.m.
2011/1/12 Jason Merrill <jason@redhat.com>:
> On 01/12/2011 05:04 AM, Richard Guenther wrote:
>>>
>>> -  type_decl = TYPE_STUB_DECL (type);
>>> +  type_decl = TYPE_STUB_DECL(TYPE_MAIN_VARIANT(type));
>>
>> Why?  That will go to the non-type-decl variant, so it seems wrong.
>
> TYPE_STUB_DECL only makes sense on the primary variant of a struct.
> cv-qualified or typedef variants don't have the stub decl, which is why the
> testcase was crashing.
>
> The patch is OK with the whitespace fix Dave pointed out.
>
> Jason
>

Applied with whitespace fix at revision 168718 to trunk.

Thanks,
Kai

Patch hide | download patch | download mbox

Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 168679)
+++ dwarf2out.c (working copy)
@@ -619,7 +619,7 @@ 
   if (criterion == DINFO_STRUCT_FILE_ANY)
     return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);

-  type_decl = TYPE_STUB_DECL (type);
+  type_decl = TYPE_STUB_DECL(TYPE_MAIN_VARIANT(type));

   if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
     return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);