https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102507
Bug ID: 102507 Summary: ICE in btf_finalize when compiling with -gbtf Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: ibhagatgnu at gmail dot com Target Milestone: --- Noticed this ICE (in gmp) when bootstrapping GCC with -gbtf as an experiment. Program received signal SIGSEGV, Segmentation fault. 0x0000000000ce775c in simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int>::is_empty<hash_map<ctf_dvdef*, unsigned int, simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int> >::hash_entry> (entry=...) at <SRC>/gcc/gcc/hash-map-traits.h:75 75 return H::is_empty (entry.m_key); Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.0.9.el7.x86_64 libgcc-4.8.5-16.el7.x86_64 libstdc++-4.8.5-16.el7.x86_64 (gdb) bt #0 0x0000000000ce775c in simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int>::is_empty<hash_map<ctf_dvdef*, unsigned int, simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int> >::hash_entry> (entry=...) at <SRC>/gcc/gcc/hash-map-traits.h:75 #1 0x0000000000ce7bab in hash_map<ctf_dvdef*, unsigned int, simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int> >::hash_entry::is_empty (e=...) at <SRC>/gcc/gcc/hash-map.h:71 #2 0x0000000000ce8623 in hash_table<hash_map<ctf_dvdef*, unsigned int, simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int> >::hash_entry, false, xcallocator>::is_empty (v=...) at <SRC>/gcc/gcc/hash-table.h:541 #3 0x0000000000ce8d30 in hash_table<hash_map<ctf_dvdef*, unsigned int, simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int> >::hash_entry, false, xcallocator>::~hash_table (this=0x7ffff088fe10, __in_chrg=<optimized out>) at <SRC>/gcc/gcc/hash-table.h:681 #4 0x0000000000ce8c20 in hash_map<ctf_dvdef*, unsigned int, simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int> >::~hash_map (this=0x7ffff088fe10, __in_chrg=<optimized out>) at <SRC>/gcc/gcc/hash-map.h:39 #5 0x0000000000ce8c3a in finalize<hash_map<ctf_dvdef*, unsigned int, simple_hashmap_traits<default_hash_traits<ctf_dvdef*>, unsigned int> > > (p=0x7ffff088fe10) at <SRC>/gcc/gcc/ggc.h:162 #6 0x0000000000c31dd2 in finalizer::call (this=0x3fd29f8) at <SRC>/gcc/gcc/ggc-page.c:333 #7 0x0000000000c304be in ggc_handle_finalizers () at <SRC>/gcc/gcc/ggc-page.c:1928 #8 0x0000000000c30bd7 in ggc_collect (mode=GGC_COLLECT_HEURISTIC) at <SRC>/gcc/gcc/ggc-page.c:2228 #9 0x0000000001244668 in execute_one_pass (pass=0x3f2e730) at <SRC>/gcc/gcc/passes.c:2639 #10 0x00000000012446dd in execute_pass_list_1 (pass=0x3f2e730) at <SRC>/gcc/gcc/passes.c:2656 #11 0x0000000001244764 in execute_pass_list (fn=0x7ffff077f600, pass=0x3f2e6d0) at <SRC>/gcc/gcc/passes.c:2667 #12 0x00000000012426a6 in do_per_function_toporder (callback=0x1244727 <execute_pass_list(function*, opt_pass*)>, data=0x3f2e6d0) at <SRC>/gcc/gcc/passes.c:1773 #13 0x0000000001245384 in execute_ipa_pass_list (pass=0x3f2e670) at <SRC>/gcc/gcc/passes.c:3003 #14 0x0000000000d1299a in ipa_passes () at <SRC>/gcc/gcc/cgraphunit.c:2154 #15 0x0000000000d12dcc in symbol_table::compile (this=0x7ffff08c6000) at <SRC>/gcc/gcc/cgraphunit.c:2289 #16 0x0000000000d13326 in symbol_table::finalize_compilation_unit (this=0x7ffff08c6000) at <SRC>/gcc/gcc/cgraphunit.c:2537 #17 0x00000000013a19fd in compile_file () at <SRC>/gcc/gcc/toplev.c:483 #18 0x00000000013a4b11 in do_compile () at <SRC>/gcc/gcc/toplev.c:2233 #19 0x00000000013a4df7 in toplev::main (this=0x7fffffffdcf0, argc=24, argv=0x7fffffffddf8) at <SRC>/gcc/gcc/toplev.c:2372 #20 0x00000000029109f2 in main (argc=24, argv=0x7fffffffddf8) at <SRC>/gcc/gcc/main.c:39 Looks like the garbage collector, when cleaning up the btf_var_ids hash_map, is working on invalid memory and bails out.