Closed NicholasLYang closed 1 year ago
The Allocator
needs to have enough space in its first segment for the entire message. When you do Builder::new(HeapAllocator::default())
, your allocator has a first segment size of 1024 words: https://github.com/capnproto/capnproto-rust/blob/dd9c072ce48c8e5377b3844ecaca832749eece08/capnp/src/message.rs#L661
Here's how the canoncalize()
function makes sure there is enough space:
https://github.com/capnproto/capnproto-rust/blob/dd9c072ce48c8e5377b3844ecaca832749eece08/capnp/src/message.rs#L288-L290
(Hm... looking at that now, I'm not sure about that + 1
there. Maybe target_size()
is enough in itself and that's a (relatively harmless) bug.)
Ah gotcha. Thanks!
Hi,
We've started getting errors because this assertion in
set_root_canonical
is false:We're calling it to canonicalize a message, specifically right here. Is there a specific reason why the assertion is false? Do we need to do something else before calling this function?