Question

I am having a strange problem I do not know how to debug:

I have the following (C++11) class method:

void RamCloud::write(uint32_t tableId, uint64_t id, const void* buf,
                     uint32_t length,
                     uint64_t* version, bool async)
{
    btree::node_cache& cache = btree::node_cache::instance(104857600);
        cache.write(tableId, id, buf, length);
    theCloud->write(tableId, id, buf, length, nullptr, version, async);
}

(don't thing too much what the code does, it does not really matter here).

Most of the time this works, but there is one case where it does fail. If I break at the last line using gdb, I can do the following:

(gdb) p theCloud
$3 = (RAMCloud::RamCloud *) 0x7fbe14009e90
(gdb) p tableId
$5 = 3
(gdb) p id
$6 = 3
(gdb) p buf
$7 = (const void *) 0x7fbe253a22d0
(gdb) p length
$8 = 31496
(gdb) p version
$9 = (uint64_t *) 0x0
(gdb) p async
$10 = false
(gdb) s
#0  0x00007fbe220344aa in RAMCloud::RamCloud::write (this=0x0, tableId=0, id=0, buf=0x0, length=0, rejectRules=0x0, version=0x0, async=false) at /local/mpilman/ramcloudarch/ramcloud/src/RamCloud.cc:260
(gdb) p this
$11 = (RAMCloud::RamCloud * const) 0x0
(gdb) p tableId
$12 = 0
(gdb) p id
$13 = 0
(gdb) p buf
$14 = (const void *) 0x0
(gdb) p length
$15 = 0
(gdb) p rejectRules 
$16 = (const RAMCloud::RejectRules *) 0x0
(gdb) p version
$17 = (uint64_t *) 0x0
(gdb) p async
$18 = false

So right before the call everything seems ok, but after the call, all arguments (including the this pointer) switch to null. When I try to continue I get of course a segfault...

So my question: what could be here the problem? The caller is in another library than the callee, but these libraries are linked statically (and everything is compiled with the same compiler).

gcc version is 4.6.1. Does anyone have an idea where I could start debugging?

Thanks for any help!

Was it helpful?

Solution

It looks like your stack is being smashed. Tools like Valgrind on *nix or Application Verifier on Windows can be used to find the cause of these memory-related problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top