jinxuan / sparsehash

Automatically exported from code.google.com/p/sparsehash
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Assertion failure in densehashtable.h:489 test_empty() function #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I just moved from C++ hash_map<> to a dense_hash_map<> implementation. 

My hash_map<> worked fine and just made "hash_map" to "dense_hash_map".

But now, the dense_hash_map asserts, below is my call stack. Looks like the 
empty check is broken. 

From call stack you can see that it happened when trying to insert an item. 

(gdb) bt
#0  0x000000332fa30265 in raise () from /lib64/libc.so.6
#1  0x000000332fa31d10 in abort () from /lib64/libc.so.6
#2  0x000000332fa296e6 in __assert_fail () from /lib64/libc.so.6
#3  0x00007f66be6fe304 in google::dense_hashtable<std::pair<unsigned long 
const, DeadInfo>, unsigned long, __gnu_cxx::hash<unsigned long>, 
google::dense_hash_map<unsigned long, DeadInfo, __gnu_cxx::hash<unsigned long>, 
std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::SelectKey, google::dense_hash_map<unsigned long, DeadInfo, 
__gnu_cxx::hash<unsigned long>, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::SetKey, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::test_empty (this=0x7f66c2c7b160, bucknum=1) at 
/projects/hpc/mc29/software/sparsehash-1.11/src/google/sparsehash/densehashtable
.h:489
#4  0x00007f66be6fe3a1 in google::dense_hashtable<std::pair<unsigned long 
const, DeadInfo>, unsigned long, __gnu_cxx::hash<unsigned long>, 
google::dense_hash_map<unsigned long, DeadInfo, __gnu_cxx::hash<unsigned long>, 
std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::SelectKey, google::dense_hash_map<unsigned long, DeadInfo, 
__gnu_cxx::hash<unsigned long>, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::SetKey, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::find_position (this=0x7f66c2c7b160, key=@0x7f66bd41eb88) at 
/projects/hpc/mc29/software/sparsehash-1.11/src/google/sparsehash/densehashtable
.h:843
#5  0x00007f66be704c21 in google::dense_hashtable<std::pair<unsigned long 
const, DeadInfo>, unsigned long, __gnu_cxx::hash<unsigned long>, 
google::dense_hash_map<unsigned long, DeadInfo, __gnu_cxx::hash<unsigned long>, 
std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::SelectKey, google::dense_hash_map<unsigned long, DeadInfo, 
__gnu_cxx::hash<unsigned long>, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::SetKey, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::find_or_insert<google::dense_hash_map<unsigned long, DeadInfo, 
__gnu_cxx::hash<unsigned long>, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::DefaultValue> (this=0x7f66c2c7b160, key=@0x7f66bd41eb88) at 
/projects/hpc/mc29/software/sparsehash-1.11/src/google/sparsehash/densehashtable
.h:1001
#6  0x00007f66be704d69 in google::dense_hash_map<unsigned long, DeadInfo, 
__gnu_cxx::hash<unsigned long>, std::equal_to<unsigned long>, 
google::libc_allocator_with_realloc<std::pair<unsigned long const, DeadInfo> > 
>::operator[] (this=0x7f66c2c7b160, key=@0x7f66bd41eb88) at 
/projects/hpc/mc29/software/sparsehash-1.11/src/google/dense_hash_map:264
#7  0x00007f66be6f27ba in Record8ByteMemWrite(uint32_t, LEVEL_BASE::._84::VOID 
*) (slot=0, addr=0x332ec1bc60) at pinatrace.dev.cpp:2026

Original issue reported on code.google.com by milis...@gmail.com on 27 Aug 2011 at 10:59

GoogleCodeExporter commented 9 years ago
dense_hash_map is not quite a drop-in replacement for hash_map.  You also need 
to call set_empty_key().  See the comments at the top of dense_hash_map, or the 
dense_hash_map docs in the docs/ folder.

Original comment by csilv...@gmail.com on 28 Aug 2011 at 1:17