Hi,

We are trying to use capnp (0.5.3) for inter-process communication. For 
that we are going to use a shared memory organized as a ring buffer 
(between C++ and Rust apps).
The allocateSegment() method (in C++) is allocating a chunk of unused 
memory and returns it as kj::array.
Unfortunately we noticed that if the underlining memory chunk (which is 
reused, as we have a ring buffer) is not nullified, that is memset(0) for 
the whole size, capn'p would crash.
Further analysis revealed that the library tries to read from the newly 
allocated chunk at the function WireHelpers::zeroObject by putting a read 
watch on the newly allocated memory chunk:

#0  0x000000000064af43 in 
capnp::_::WireHelpers::zeroObject(capnp::_::SegmentBuilder*, 
capnp::_::WirePointer*) ()
#1  0x00000000006468e8 in 
capnp::_::PointerBuilder::initStruct(capnp::_::StructSize) ()
#2  0x0000000000425d9c in capnp::_::PointerHelpers<Test, 
(capnp::Kind)3>::init (builder=...) at 
/sandbox/common/include/capnp/pointer-helpers.h:52
#3  0x00000000004259e6 in capnp::AnyPointer::Builder::initAs<Test> 
(this=0x7ffff6b0dd10) at /sandbox/common/include/capnp/any.h:690
#4  0x000000000042557e in capnp::MessageBuilder::initRoot<Test> 
(this=0x7ffff6b0ddd0) at /sandbox/common/include/capnp/message.h:432
#5  0x00000000004241c6 in MsgWriterRunner::run (this=0x96bbc8) at 
/sandbox/mylib/unittest/capnp_message_test.cpp:246
...

The capnp is simple
struct Test {
  name @0 :Text;
  number @1 : UInt64;
}

Looking at MallocBuilder we notice the calloc() is actually used, that is 
buffers are always zeroed.


Is that an implicit requirement that the memory returned by the overriding 
allocateSegment is zeroed?
If so, it would have significant implications on the performance, which is 
the reson we chose Capn'p in the first place.

Any assistance appreciated.

A side question: what is the right way to build a debug version of the 
libraries on linux? Found no documentation on that; tried .configure with 
-DDEBUG but the results are not satisfying - some functions remain inlined.

Thanks,
Roman.

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to