public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g
@ 2011-01-07 12:41 zsojka at seznam dot cz
  2011-01-07 23:59 ` [Bug debug/47209] " zsojka at seznam dot cz
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2011-01-07 12:41 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ICE: SIGSEGV in should_emit_struct_debug
                    (dwarf2out.c:627) with -femit-struct-debug-baseonly -g
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zsojka@seznam.cz


Created attachment 22923
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22923
reduced testcase

Compiler output:
$ gcc -femit-struct-debug-baseonly -g pr47209.C
==21262== Invalid read of size 2
==21262==    at 0x78AC0E: should_emit_struct_debug (dwarf2out.c:627)
==21262==    by 0x7BAA0C: dwarf2out_imported_module_or_decl (dwarf2out.c:21164)
==21262==    by 0x678056: cp_emit_debug_info_for_using (name-lookup.c:5653)
==21262==    by 0x5A6D80: check_bases_and_members (class.c:1204)
==21262==    by 0x5A9DC1: finish_struct_1 (class.c:5531)
==21262==    by 0x5AB834: finish_struct (class.c:5760)
==21262==    by 0x5D0FC9: cp_parser_type_specifier (parser.c:16919)
==21262==    by 0x5D24E7: cp_parser_decl_specifier_seq (parser.c:9969)
==21262==    by 0x5E97BA: cp_parser_simple_declaration (parser.c:9626)
==21262==    by 0x5E9BE6: cp_parser_block_declaration (parser.c:9587)
==21262==    by 0x5ED8F1: cp_parser_declaration (parser.c:9492)
==21262==    by 0x5EC419: cp_parser_declaration_seq_opt (parser.c:9378)
==21262==    by 0x5EDF68: c_parse_file (parser.c:3461)
==21262==    by 0x6C2194: c_common_parse_file (c-opts.c:1071)
==21262==    by 0xA24597: toplev_main (toplev.c:579)
==21262==    by 0x6369BBC: (below main) (in /lib64/libc-2.11.2.so)
==21262==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==21262== 
pr47209.C:6:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r168552 - crash
4.5.2, 4.4.5, 4.3.5 - crash
4.2.4 - doesn't know -femit-struct-debug-baseonly

In the testcase, "  base::foo;" can be changes to "using base::foo;", it will
still fail.


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
@ 2011-01-07 23:59 ` zsojka at seznam dot cz
  2011-01-08  4:59 ` hjl.tools at gmail dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2011-01-07 23:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Zdenek Sojka <zsojka at seznam dot cz> 2011-01-07 23:42:49 UTC ---
I don't know if the code is valid or invalid (I have no clue what is the
meaning of "base::foo;"). Comeau online and icc 11.1 accept it though.
If it is not valid, changing "base::foo;" to "using base::foo;" probably makes
it valid.


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
  2011-01-07 23:59 ` [Bug debug/47209] " zsojka at seznam dot cz
@ 2011-01-08  4:59 ` hjl.tools at gmail dot com
  2011-01-08 20:59 ` [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g zsojka at seznam dot cz
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2011-01-08  4:59 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.01.08 04:17:00
                 CC|                            |iant at google dot com
     Ever Confirmed|0                           |1

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2011-01-08 04:17:00 UTC ---
-femit-struct-debug-baseonly failed from the very beginning with
revision 123909:

http://gcc.gnu.org/ml/gcc-cvs/2007-04/msg00521.html


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
  2011-01-07 23:59 ` [Bug debug/47209] " zsojka at seznam dot cz
  2011-01-08  4:59 ` hjl.tools at gmail dot com
@ 2011-01-08 20:59 ` zsojka at seznam dot cz
  2011-01-08 21:00 ` ktietz at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2011-01-08 20:59 UTC (permalink / raw)
  To: gcc-bugs

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

Zdenek Sojka <zsojka at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE: SIGSEGV in             |ICE: SIGSEGV in
                   |should_emit_struct_debug    |should_emit_struct_debug
                   |(dwarf2out.c:627) with      |(dwarf2out.c:627) with
                   |-femit-struct-debug-baseonl |-f{no-,}emit-struct-debug-{
                   |y -g                        |baseonly,reduced} -g

--- Comment #3 from Zdenek Sojka <zsojka at seznam dot cz> 2011-01-08 20:45:38 UTC ---
It fails the same way with -f{no-,}emit-struct-debug-reduced and
-f{no-,}emit-struct-debug-baseonly , with very similiar crash location and the
same backtrace:

$ gcc -femit-struct-debug-reduced -g pr47209.C
==15753== Invalid read of size 2
==15753==    at 0x78AC90: should_emit_struct_debug (dwarf2out.c:624)
pr47209.C:6:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

$ gcc -fno-emit-struct-debug-reduced -g pr47209.C
==15579== Invalid read of size 2
==15579==    at 0x78AC90: should_emit_struct_debug (dwarf2out.c:624)
pr47209.C:6:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

$ gcc -femit-struct-debug-baseonly -g pr47209.C
==5087== Invalid read of size 2
==5087==    at 0x78AC0E: should_emit_struct_debug (dwarf2out.c:627)
pr47209.C:6:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

$ gcc -fno-emit-struct-debug-baseonly -g pr47209.C
==13603== Invalid read of size 2
==13603==    at 0x78AC0E: should_emit_struct_debug (dwarf2out.c:627)
pr47209.C:6:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

(In reply to comment #1)
> I don't know if the code is valid or invalid (I have no clue what is the
> meaning of "base::foo;").

According to people ##C++ at irc.freenode.org, it is equivalent to "using
base::foo;", in some pre-standard notation (if I understood that correctly).


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2011-01-08 20:59 ` [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g zsojka at seznam dot cz
@ 2011-01-08 21:00 ` ktietz at gcc dot gnu.org
  2011-01-09  2:11 ` zsojka at seznam dot cz
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ktietz at gcc dot gnu.org @ 2011-01-08 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktietz at gcc dot gnu.org

--- Comment #4 from Kai Tietz <ktietz at gcc dot gnu.org> 2011-01-08 20:55:20 UTC ---
Well, the issue here seems to be that in should_emit_struct_debug
TYPE_STUB_DECL (type) for provided type is a NULL_TREE. In next two
if-statements this result is used unconditionally. I am not sure if the
underlying issue is related to some other place in c++ FE (I assume so), but
following patch at least avoid segfault.

Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 168601)
+++ dwarf2out.c (working copy)
@@ -620,12 +620,14 @@
     return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);

   type_decl = TYPE_STUB_DECL (type);
+  if (type_decl != NULL_TREE)
+    {
+      if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER
(type_decl))
+       return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);

-  if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
-    return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
-
-  if (matches_main_base (DECL_SOURCE_FILE (type_decl)))
-    return DUMP_GSTRUCT (type, usage, criterion, generic, true, true);
+      if (matches_main_base (DECL_SOURCE_FILE (type_decl)))
+       return DUMP_GSTRUCT (type, usage, criterion, generic, true, true);
+    }
   return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
 }


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2011-01-08 21:00 ` ktietz at gcc dot gnu.org
@ 2011-01-09  2:11 ` zsojka at seznam dot cz
  2011-01-12 17:10 ` ktietz at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2011-01-09  2:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Zdenek Sojka <zsojka at seznam dot cz> 2011-01-09 01:17:54 UTC ---
Created attachment 22933
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22933
different testcase

(In reply to comment #4)
> Well, the issue here seems to be that in should_emit_struct_debug
> TYPE_STUB_DECL (type) for provided type is a NULL_TREE. In next two
> if-statements this result is used unconditionally. I am not sure if the
> underlying issue is related to some other place in c++ FE (I assume so), but
> following patch at least avoid segfault.

It fixes attached testcase as well:

Without patch:
$ gcc -fopenmp -femit-struct-debug-reduced -g pr47209-2.C 
==10408== Invalid read of size 2
==10408==    at 0x78AD70: should_emit_struct_debug (dwarf2out.c:624)
==10408==    by 0x7B9790: gen_tagged_type_die (dwarf2out.c:20117)
==10408==    by 0x7BA774: gen_typedef_die.part.160 (dwarf2out.c:20266)
==10408==    by 0x7B84BB: gen_decl_die (dwarf2out.c:21056)
==10408==    by 0x7AC9BD: gen_type_die_with_usage (dwarf2out.c:20412)
==10408==    by 0x7AD0F5: gen_type_die_with_usage (dwarf2out.c:20454)
==10408==    by 0x7B8355: gen_decl_die (dwarf2out.c:21119)
==10408==    by 0x7B5DFE: gen_subprogram_die (dwarf2out.c:19330)
==10408==    by 0x7B8142: gen_decl_die (dwarf2out.c:21033)
==10408==    by 0x7BB678: dwarf2out_function_decl (dwarf2out.c:21415)
==10408==    by 0x8141FC: rest_of_handle_final (final.c:4296)
==10408==    by 0x93B5D5: execute_one_pass (passes.c:1553)
==10408==    by 0x93B8C4: execute_pass_list (passes.c:1608)
==10408==    by 0x93B8D6: execute_pass_list (passes.c:1609)
==10408==    by 0x93B8D6: execute_pass_list (passes.c:1609)
==10408==    by 0xA7B995: tree_rest_of_compilation (tree-optimize.c:422)
==10408==    by 0xC40D21: cgraph_expand_function (cgraphunit.c:1519)
==10408==    by 0xC436DC: cgraph_optimize (cgraphunit.c:1672)
==10408==    by 0xC43969: cgraph_finalize_compilation_unit (cgraphunit.c:1042)
==10408==    by 0x5B7E2C: cp_write_global_declarations (decl2.c:3974)
==10408==    by 0xA25165: toplev_main (toplev.c:591)
==10408==    by 0x6369BBC: (below main) (in /lib64/libc-2.11.2.so)
==10408==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==10408== 
pr47209-2.C: In function '<built-in>':
pr47209-2.C:9:9: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


With patch:
$ gcc -fopenmp -femit-struct-debug-reduced -g pr47209-2.C -c

(no output)


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2011-01-09  2:11 ` zsojka at seznam dot cz
@ 2011-01-12 17:10 ` ktietz at gcc dot gnu.org
  2011-01-12 17:17 ` ktietz at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ktietz at gcc dot gnu.org @ 2011-01-12 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Kai Tietz <ktietz at gcc dot gnu.org> 2011-01-12 17:02:51 UTC ---
Author: ktietz
Date: Wed Jan 12 17:02:41 2011
New Revision: 168718

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168718
Log:
2011-01-12  Kai Tietz  <kai.tietz@onevision.com>

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

2011-01-12  Kai Tietz  <kai.tietz@onevision.com>

    PR debug/47209
    * g++.dg/debug/pr47209.C: New.


Added:
    trunk/gcc/testsuite/g++.dg/debug/pr47209.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2011-01-12 17:10 ` ktietz at gcc dot gnu.org
@ 2011-01-12 17:17 ` ktietz at gcc dot gnu.org
  2024-03-25  5:13 ` pinskia at gcc dot gnu.org
  2024-03-25  5:13 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ktietz at gcc dot gnu.org @ 2011-01-12 17:17 UTC (permalink / raw)
  To: gcc-bugs

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

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Kai Tietz <ktietz at gcc dot gnu.org> 2011-01-12 17:06:15 UTC ---
Fixed.


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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2011-01-12 17:17 ` ktietz at gcc dot gnu.org
@ 2024-03-25  5:13 ` pinskia at gcc dot gnu.org
  2024-03-25  5:13 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-25  5:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47209

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.6.0

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

* [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g
  2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2024-03-25  5:13 ` pinskia at gcc dot gnu.org
@ 2024-03-25  5:13 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-25  5:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47209

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pawel_sikora at zoho dot com

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 49162 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2024-03-25  5:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-07 12:41 [Bug debug/47209] New: ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -femit-struct-debug-baseonly -g zsojka at seznam dot cz
2011-01-07 23:59 ` [Bug debug/47209] " zsojka at seznam dot cz
2011-01-08  4:59 ` hjl.tools at gmail dot com
2011-01-08 20:59 ` [Bug debug/47209] ICE: SIGSEGV in should_emit_struct_debug (dwarf2out.c:627) with -f{no-,}emit-struct-debug-{baseonly,reduced} -g zsojka at seznam dot cz
2011-01-08 21:00 ` ktietz at gcc dot gnu.org
2011-01-09  2:11 ` zsojka at seznam dot cz
2011-01-12 17:10 ` ktietz at gcc dot gnu.org
2011-01-12 17:17 ` ktietz at gcc dot gnu.org
2024-03-25  5:13 ` pinskia at gcc dot gnu.org
2024-03-25  5:13 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).