Lendfating / leveldb

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

SIGABRT when db.Get() on OSX #193

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile the following code

int main() {
  leveldb::DB* db;
  leveldb::Options options;
  options.create_if_missing = true;
  auto status = leveldb::DB::Open(options, "test.db", &db);
  assert(status.ok());

  db->Put(leveldb::WriteOptions(), "2", "23");
  string value;
  db->Get(leveldb::ReadOptions(), "2", &value);
  delete db;
  return 0;
}

2. Compile it with "g++ -std=c++11 -lleveldb test.cpp"
3. Run it

What is the expected output? What do you see instead?
db->Get() should set value to "23". 

It crashes with the output:

a.out(32275,0x7fff7d3dc180) malloc: *** error for object 0x1074da820: pointer 
being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Here is the GDB output

(gdb) r
Starting program: /Users/eddyxu/tmp/a.out
Reading symbols for shared libraries ++++................................ done
a.out(32295,0x7fff7d3dc180) malloc: *** error for object 0x100123820: pointer 
being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Program received signal SIGABRT, Aborted.
0x00007fff98846212 in __pthread_kill ()
(gdb) bt
#0  0x00007fff98846212 in __pthread_kill ()
#1  0x00007fff969c9b54 in pthread_kill ()
#2  0x00007fff96a0ddce in abort ()
#3  0x00007fff969e19b9 in free ()
#4  0x00007fff959af780 in std::string::_M_mutate ()
#5  0x00007fff959b0317 in std::string::_M_replace_safe ()
#6  0x00000001000108ab in leveldb::MemTable::Get ()
#7  0x0000000100009d34 in leveldb::DBImpl::Get ()
#8  0x0000000100000acc in main ()

What version of the product are you using? On what operating system?

Leveldb 1.12.0 on Mac OSX 10.8.3, g++ 4.7.3

Please provide any additional information below.

Original issue reported on code.google.com by edd...@gmail.com on 23 Jul 2013 at 8:11

GoogleCodeExporter commented 9 years ago
i have a multi-threaded app which seems to be exhibiting the same sort of 
"freeing unallocated pointer" problem from inside leveldb.  my stack is:

pddb(80102,0x100481000) malloc: *** error for object 0x10000100c: pointer being 
freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Process 80102 stopped
* thread #2: tid = 0x7e1911, 0x00007fff90294866 
libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
    frame #0: 0x00007fff90294866 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill + 10:
-> 0x7fff90294866:  jae    0x7fff90294870            ; __pthread_kill + 20
   0x7fff90294868:  movq   %rax, %rdi
   0x7fff9029486b:  jmpq   0x7fff90291175            ; cerror_nocancel
   0x7fff90294870:  ret    
(lldb) bt
* thread #2: tid = 0x7e1911, 0x00007fff90294866 
libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
  * frame #0: 0x00007fff90294866 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff869df35c libsystem_pthread.dylib`pthread_kill + 92
    frame #2: 0x00007fff8ad0fb1a libsystem_c.dylib`abort + 125
    frame #3: 0x00007fff8ec0407f libsystem_malloc.dylib`free + 411
    frame #4: 0x0000000100024051 libleveldb.1.15.dylib`leveldb::DeleteCachedBlock(leveldb::Slice const&, void*) + 23
    frame #5: 0x000000010002695f libleveldb.1.15.dylib`leveldb::(anonymous namespace)::LRUCache::Unref(leveldb::(anonymous namespace)::LRUHandle*) + 75
    frame #6: 0x00000001000266a5 libleveldb.1.15.dylib`leveldb::(anonymous namespace)::ShardedLRUCache::Insert(leveldb::Slice const&, void*, unsigned long, void (*)(leveldb::Slice const&, void*)) + 523
    frame #7: 0x0000000100023f62 libleveldb.1.15.dylib`leveldb::Table::BlockReader(void*, leveldb::ReadOptions const&, leveldb::Slice const&) + 588
    frame #8: 0x0000000100024208 libleveldb.1.15.dylib`leveldb::Table::InternalGet(leveldb::ReadOptions const&, leveldb::Slice const&, void*, void (*)(void*, leveldb::Slice const&, leveldb::Slice const&)) + 274
    frame #9: 0x0000000100018c51 libleveldb.1.15.dylib`leveldb::TableCache::Get(leveldb::ReadOptions const&, unsigned long long, unsigned long long, leveldb::Slice const&, void*, void (*)(void*, leveldb::Slice const&, leveldb::Slice const&)) + 109
    frame #10: 0x000000010001ab6d libleveldb.1.15.dylib`leveldb::Version::Get(leveldb::ReadOptions const&, leveldb::LookupKey const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, leveldb::Version::GetStats*) + 931
    frame #11: 0x000000010000f155 libleveldb.1.15.dylib`leveldb::DBImpl::Get(leveldb::ReadOptions const&, leveldb::Slice const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) + 337
    frame #12: 0x0000000100009dc0 libleveldb.1.15.dylib`leveldb_get + 72
    frame #13: 0x0000000100001732 pddb`pddb_worker(arg=0x00000001000033b0) + 130 at pddb.c:761
    frame #14: 0x00007fff869de899 libsystem_pthread.dylib`_pthread_body + 138
    frame #15: 0x00007fff869de72a libsystem_pthread.dylib`_pthread_start + 137

im running leveldb-1.15 which seems to be "current".  any ideas?  (this seems 
to work fine under linux, but when running on mac osx, it crashes in like 2 
min.)

Original comment by circl...@gmail.com on 20 Apr 2014 at 4:10