epitzer / sparsehash

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

Memory Corruption #90

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
class A {
   A(bool, size_t expectedSize) {
         m_something.set_empty_key(-1);
         m_something.set_deleted_key(-2);
         m_something.set_min_load_factor(0);
         m_something.resize(expectedSize);
   }

   struct SometStruct { long a; long b; }
   google::dense_hash_map<long, SomeStruct*> m_something;
}
2. Then somewhere in the code, I called new A();
3. Then, I ran valgrind, and the very first invalid write was inside  sparse 
hashmap.

What is the expected output? What do you see instead?
Shouldn't have any invalid write reported by valgrind

What version of the product are you using? On what operating system?
I downloaded the latest around last Nov.  Should be the latest.
CentOS 6 64-bit.
gcc 4.4.1.

Please provide any additional information below.

==27468== Invalid write of size 1
==27468==    at 0x41B4ED: 
google::sparsehash_internal::sh_hashtable_settings<long, std::tr1::hash<long>, 
unsigned long, 4>::sh_hashtable_settings(std::tr1::hash<long> const&, float, 
float) (hashtable-common.h:237)
==27468==    by 0x419B26: google::dense_hashtable<std::pair<long const, 
A::SomeStruct*>, long, std::tr1::hash<long>, google::dense_hash_map<long, 
A::SomeStruct*, std::tr1::hash<long>, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::SelectKey, google::dense_hash_map<long, A::SomeStruct*, 
std::tr1::hash<long>, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::SetKey, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::Settings::Settings(std::tr1::hash<long> const&) (densehashtable.h:1233)
==27468==    by 0x4188CB: google::dense_hashtable<std::pair<long const, 
A::SomeStruct*>, long, std::tr1::hash<long>, google::dense_hash_map<long, 
A::SomeStruct*, std::tr1::hash<long>, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::SelectKey, google::dense_hash_map<long, A::SomeStruct*, 
std::tr1::hash<long>, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::SetKey, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::dense_hashtable(unsigned long, std::tr1::hash<long> const&, 
std::equal_to<long> const&, google::dense_hash_map<long, A::SomeStruct*, 
std::tr1::hash<long>, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::SelectKey const&, google::dense_hash_map<long, A::SomeStruct*, 
std::tr1::hash<long>, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::SetKey const&, google::libc_allocator_with_realloc<std::pair<long const, 
A::SomeStruct*> > const&) (densehashtable.h:698)
==27468==    by 0x418007: google::dense_hash_map<long, A::SomeStruct*, 
std::tr1::hash<long>, std::equal_to<long>, 
google::libc_allocator_with_realloc<std::pair<long const, A::SomeStruct*> > 
>::dense_hash_map(unsigned long, std::tr1::hash<long> const&, 
std::equal_to<long> const&, google::libc_allocator_with_realloc<std::pair<long 
const, A::SomeStruct*> > const&) (dense_hash_map:189)
==27468==    by 0x4177A0: A::A(bool, unsigned long) (A.cpp:14)

Original issue reported on code.google.com by hchan1980@gmail.com on 3 Feb 2013 at 8:51

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Please close this ticket as the issue goes away after I use #include 
<sparsehash/dense_hash_map> instead of #include <google/dense_hash_map>.

Original comment by hchan1980@gmail.com on 3 Feb 2013 at 10:07