I just tried this again and the source of this problem does not seem to be memcpy vs memmove but that Append tries to copy data to unallocated memory. Note below that limit_ points to a string "wp/labels". This may indicate a stack overflow, I guess (Though I'm not too proficient in debugging C++).
My test machine is running x86_64 (intel), ruby 1.9.3p194 and leveldb-ruby built from git HEAD. Program received signal SIGBUS, Bus error. 0x00007ffff7753ceb in __memcpy_ssse3_back () from /lib/libc.so.6 (gdb) bt #0 0x00007ffff7753ceb in __memcpy_ssse3_back () from /lib/libc.so.6 #1 0x00007ffff3777181 in leveldb::(anonymous namespace)::PosixMmapFile::Append (this=0x107d760, data=...) at util/env_posix.cc:227 #2 0x00007ffff3757cbc in leveldb::log::Writer::EmitPhysicalRecord (this=0x1009af0, t=leveldb::log::kFullType, ptr=0x10065d8 "\264\n", n=150) at db/log_writer.cc:93 #3 0x00007ffff3757a9a in leveldb::log::Writer::AddRecord (this=0x1009af0, slice=...) at db/log_writer.cc:67 #4 0x00007ffff374980e in leveldb::DBImpl::Write (this=0x107aa40, options=..., my_batch=0x7fffffffdb00) at db/db_impl.cc:1140 #5 0x00007ffff374a90a in leveldb::DB::Put (this=0x107aa40, opt=..., key=..., value=...) at db/db_impl.cc:1369 #6 0x00007ffff3749573 in leveldb::DBImpl::Put (this=0x107aa40, o=..., key=..., val=...) at db/db_impl.cc:1103 (gdb) up #1 0x00007ffff3777181 in leveldb::(anonymous namespace)::PosixMmapFile::Append (this=0x107d760, data=...) at util/env_posix.cc:227 227 memcpy(dst_, src, n); (gdb) print dst_ $34 = 0x7ffff7e69fb5 "" (gdb) print n $11 = 150 (gdb) print dst_ + (n-1) $1 = 0x7ffff7e6a04a <Address 0x7ffff7e6a04a out of bounds> (gdb) print dst_ + (n-2) $2 = 0x7ffff7e6a049 <Address 0x7ffff7e6a049 out of bounds> (gdb) print dst_ + 80 $16 = 0x7ffff7e6a005 <Address 0x7ffff7e6a005 out of bounds> (gdb) print dst_ + 74 $22 = 0x7ffff7e69fff "" (gdb) print dst_ + 75 $23 = 0x7ffff7e6a000 <Address 0x7ffff7e6a000 out of bounds> (gdb) print limit_ $24 = 0x7ffff7e78000 "wp/labels" (gdb) print limit_ + 1 $25 = 0x7ffff7e78001 "p/labels" (gdb) print limit_ - 1 $26 = 0x7ffff7e77fff <Address 0x7ffff7e77fff out of bounds> (gdb) print map_size_ $28 = 65536 (gdb) print page_size_ $29 = 4096 (gdb) print base_ $30 = 0x7ffff7e68000 "\247T\210\024\036" (gdb) print last_sync_ $31 = 0x7ffff7e68000 "\247T\210\024\036" (gdb) print file_offset_ $32 = 0 _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk