Message did not contain a root pointer.

237 views
Skip to first unread message

William Zumwalt

unread,
Mar 10, 2022, 8:14:42 PM3/10/22
to Cap'n Proto
Hello,
I am getting the following error.

Exception in setting up a receiver: capnp/message.c++:99: failed: expected setment != nullptr && segment->checkObject(segment->getStartPtr(), ONE * WORDS); Message did not contain a root pointer.

Here is how I send a byte array.

    auto msg_builder = builder.initRoot<SomeMsg>();
    msg_builder.setVal(val);
   
    auto words = messageToFlatArray(msg_builder);
    auto bytes = words.asBytes();
   
    peer.send(bytes);
   
And then receive it on the other end.
    string msg;
    peer.get(msg);

    MallocMessageBuilder builder;
    const void* arr = msg.c_str();
    int len = msg.size();
   
    auto words = kj::heapArray<capnp::word>(len / sizeof(capnp::word));
    memcpy(words.begin(), arr, len);
   
    FlatArrayMessageReader reader(words);
   
    // error happens on this call
    auto m = reader.getRoot<SomeMsg>();
   
Any thoughts/hints at what's wrong? Thanks
   

William Zumwalt

unread,
Mar 11, 2022, 8:13:01 PM3/11/22
to Cap'n Proto
I'm trying to debug my problem. My sending side I can see the number of bytes which results in 55 from:

    bytes.size()
   
And the receiving side I can see it received the same number of bytes, 55.

    len    
   
Is there a shortcut way to print the contents of what was received. Some way to print the sending side serialized data of words.asBytes() and the receiving serialized data, words?

I feel like the error of not containing a root pointer means it's not finding/reading the serialized data somehow correctly.
Reply all
Reply to author
Forward
0 new messages