https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83355
Bug ID: 83355
Summary: autofdo g++.dg/bprob/g++-bprob-1.C FAILS with ICE
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: andi-gcc at firstfloor dot org
CC: marxin at gcc dot gnu.org
Target Milestone: ---
Running in gdb shows that there is a very deep recursion in get_index_by_decl
until it overflows the stack.
This patch seems to fix it (but not sure why the abstract origin would point to
itself)
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 5134a795331..403709bad6b 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -477,7 +477,7 @@ string_table::get_index_by_decl (tree decl) const
ret = get_index (lang_hooks.dwarf_name (decl, 0));
if (ret != -1)
return ret;
- if (DECL_ABSTRACT_ORIGIN (decl))
+ if (DECL_ABSTRACT_ORIGIN (decl) && DECL_ABSTRACT_ORIGIN (decl) != decl)
return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl));
return -1;
Backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x00000000016c4ab2 in pp_emit_prefix (pp=0x229b1a0 <actual_pretty_printer>) at
/home/andi/gcc/git/gcc/gcc/pretty-print.c:1485
1485 {
(gdb) up
#1 0x00000000016c4c90 in pp_append_text(pretty_printer*, char const*, char
const*) ()
at /home/andi/gcc/git/gcc/gcc/pretty-print.c:1556
1556 pp_emit_prefix (pp);
(gdb) bt
#0 0x00000000016c4ab2 in pp_emit_prefix (pp=0x229b1a0 <actual_pretty_printer>)
at /home/andi/gcc/git/gcc/gcc/pretty-print.c:1485
#1 0x00000000016c4c90 in pp_append_text(pretty_printer*, char const*, char
const*) ()
at /home/andi/gcc/git/gcc/gcc/pretty-print.c:1556
#2 0x0000000000b12c83 in pp_c_identifier (pp=0x229b1a0
<actual_pretty_printer>, id=<optimized out>)
at /home/andi/gcc/git/gcc/gcc/c-family/c-pretty-print.c:1203
#3 0x0000000000992b46 in dump_decl (flags=0, t=0x7ffff6d2ce40, pp=0x229b1a0
<actual_pretty_printer>)
at /home/andi/gcc/git/gcc/gcc/tree.h:3226
#4 dump_function_name(cxx_pretty_printer*, tree_node*, int) () at
/home/andi/gcc/git/gcc/gcc/cp/error.c:1852
#5 0x00000000009940a4 in lang_decl_name(tree_node*, int, bool) () at
/home/andi/gcc/git/gcc/gcc/cp/error.c:3005
#6 0x0000000000994133 in lang_decl_dwarf_name (decl=<optimized out>,
v=<optimized out>, translate=<optimized out>)
at /home/andi/gcc/git/gcc/gcc/cp/error.c:2977
#7 0x000000000156762a in autofdo::string_table::get_index_by_decl(tree_node*)
const ()
at /home/andi/gcc/git/gcc/gcc/auto-profile.c:477
....