This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/66496] New: Static hash_map causes segfault in static constructor of the compiler compilation unit


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

            Bug ID: 66496
           Summary: Static hash_map causes segfault in static constructor
                    of the compiler compilation unit
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jamborm at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-linux-gnu
            Target: x86_64-linux-gnu

If you define a static (non-pointer) hash_map in any gcc *.c source
code file, for example like this:

--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -139,6 +139,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-inline.h"
 #include "ipa-utils.h"

+static hash_map <tree, uint32_t> some_hash_map;
+
 template <typename valtype> class ipcp_value;

 /* Describes a particular source for an IPA-CP value.  */

ligcc will not compile, because the compiler crashes even when
compiling an empty main function.  Specifically, it segfaults in the
static constructor of the unit where you defined the hash_map:

(gdb) bt
#0  hash_table<hash_map<mem_location*, mem_usage*,
mem_alloc_description<mem_usage>::mem_alloc_hashmap_traits>::hash_entry,
xcallocator>::find_with_hash (this=this@entry=0x0,
    comparable=@0x7fffffffe000: 0x1bdc090, hash=2852224967)
    at /home/mjambor/gcc/small/src/gcc/hash-table.h:1012
#1  0x00000000009f5931 in get (k=@0x7fffffffe000: 0x1bdc090, this=0x0)
    at /home/mjambor/gcc/small/src/gcc/hash-map.h:148
#2  register_descriptor (location=0x1bdc090, ptr=0x1bc4020 <some_hash_map>,
this=<optimized out>)
    at /home/mjambor/gcc/small/src/gcc/mem-stats.h:391
#3  register_descriptor (function=0x0, line=0, filename=0x0, ggc=<optimized
out>,
    origin=<optimized out>, ptr=0x1bc4020 <some_hash_map>, this=<optimized
out>)
    at /home/mjambor/gcc/small/src/gcc/mem-stats.h:425
#4  hash_table<hash_map<tree_node*, unsigned int,
default_hashmap_traits>::hash_entry, xcallocator>::hash_table (this=0x1bc4020
<some_hash_map>, size=13, ggc=<optimized out>,
    gather_mem_stats=<optimized out>, origin=<optimized out>)
    at /home/mjambor/gcc/small/src/gcc/hash-table.h:798
#5  0x0000000000598470 in hash_map (gather_mem_stats=true, ggc=false, n=13,
    this=0x1bc4020 <some_hash_map>) at
/home/mjambor/gcc/small/src/gcc/hash-map.h:117
#6  __static_initialization_and_destruction_0 (__initialize_p=1,
__priority=65535)
    at /home/mjambor/gcc/small/src/gcc/ipa-cp.c:142
#7  _GLOBAL__sub_I_ipcp_cst_values_pool () at
/home/mjambor/gcc/small/src/gcc/ipa-cp.c:4600
#8  0x00000000012263ed in __libc_csu_init (argc=2, argv=0x7fffffffe198,
envp=0x7fffffffe1b0)
    at elf-init.c:88
#9  0x00007ffff6e4da95 in __libc_start_main () from /lib64/libc.so.6
#10 0x00000000005989d7 in _start () at ../sysdeps/x86_64/start.S:122


I know that use of static hash_maps is unlikely to be a good idea, but
it still should not crash.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]