[Bug middle-end/63544] New: [5 Regression] hash_map ends in an infinite loop if overwritten mark_empty uses a different value than 0

mliska at suse dot cz gcc-bugzilla@gcc.gnu.org
Wed Oct 15 14:38:00 GMT 2014


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

            Bug ID: 63544
           Summary: [5 Regression]  hash_map ends in an infinite loop if
                    overwritten mark_empty uses a different value than 0
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mliska at suse dot cz
                CC: tbsaunde at gcc dot gnu.org

Hello.

With following patch applied:
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 37710ca..43900c1 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1240,9 +1240,9 @@ struct profile_id_traits : default_hashmap_traits
       return e.m_key == UINT_MAX;
     }

-  template<typename T> static bool is_empty (T &e) { return e.m_key == 0; }
+  template<typename T> static bool is_empty (T &e) { return e.m_key ==
UINT_MAX - 1; }
   template<typename T> static void mark_deleted (T &e) { e.m_key = UINT_MAX; }
-  template<typename T> static void mark_empty (T &e) { e.m_key = 0; }
+  template<typename T> static void mark_empty (T &e) { e.m_key = UINT_MAX - 1;
}
 };

 static hash_map<unsigned int, cgraph_node *, profile_id_traits> *

I configured GCC: ../configure --enable-languages=c,c++ --disable-libsanitizer
--disable-multilib
and run: make profiledbootstrap

After stage1 compiler is built, I loop in:
#0  hash_map<unsigned int, cgraph_node*,
profile_id_traits>::hash_entry::is_deleted (e=...) at ../../gcc/hash-map.h:132
#1  0x0000000000f4bb14 in is_deleted_helper<hash_map<unsigned int,
cgraph_node*, profile_id_traits>::hash_entry, hash_map<unsigned int,
cgraph_node*, profile_id_traits>::hash_entry, false>::call (v=...) at
../../gcc/hash-table.h:392
#2  0x0000000000f4b375 in hash_table<hash_map<unsigned int, cgraph_node*,
profile_id_traits>::hash_entry, xcallocator, true>::is_deleted (v=...) at
../../gcc/hash-table.h:1170
#3  0x0000000000f4b0cc in hash_table<hash_map<unsigned int, cgraph_node*,
profile_id_traits>::hash_entry, xcallocator, true>::find_with_hash
(this=0x29c7e00, comparable=@0x7f3fd57042e0: 108032747, hash=108032747) at
../../gcc/hash-table.h:1435
#4  0x0000000000f4a662 in hash_map<unsigned int, cgraph_node*,
profile_id_traits>::get (this=0x29c7e00, k=@0x7f3fd57042e0: 108032747)
    at ../../gcc/hash-map.h:220
#5  0x0000000000f4810c in init_node_map (local=true) at
../../gcc/value-prof.c:1280
#6  0x0000000000d3b298 in tree_profiling () at ../../gcc/tree-profile.c:584
#7  0x0000000000d3b75d in (anonymous namespace)::pass_ipa_tree_profile::execute
(this=0x29d5e90) at ../../gcc/tree-profile.c:709
#8  0x0000000000b643cb in execute_one_pass (pass=0x29d5e90) at
../../gcc/passes.c:2151
#9  0x0000000000b6517b in execute_ipa_pass_list (pass=0x29d5e90) at
../../gcc/passes.c:2541
#10 0x0000000000804083 in ipa_passes () at ../../gcc/cgraphunit.c:2012
#11 0x0000000000804422 in symbol_table::compile (this=0x7f3fd56f5000) at
../../gcc/cgraphunit.c:2131
#12 0x000000000080475c in symbol_table::finalize_compilation_unit
(this=0x7f3fd56f5000) at ../../gcc/cgraphunit.c:2284
#13 0x0000000000663d4a in c_write_global_declarations () at
../../gcc/c/c-decl.c:10633
#14 0x0000000000c5b98a in compile_file () at ../../gcc/toplev.c:565
#15 0x0000000000c5dc88 in do_compile () at ../../gcc/toplev.c:1973
#16 0x0000000000c5ddf3 in toplev_main (argc=26, argv=0x7fff49285938) at
../../gcc/toplev.c:2049
#17 0x0000000001523bb0 in main (argc=26, argv=0x7fff49285938) at
../../gcc/main.c:36

Thank you for help,
Martin



More information about the Gcc-bugs mailing list