Kenton,
On Friday, March 2, 2018 at 7:27:30 PM UTC+1, Kenton Varda wrote:
>
> Hi Marc,
>
> Do you have any custom type handlers registered via addTypeHandler()? Is
> it possible that the handler class has gone out-of-scope (been destroyed)
> by the time the encoder is executed?
>
No, I am not using custom handlers. I am just dumping the Builder like this
(simplified):
template<typename T>
void dump_msg(T& msg){
try{
capnp::JsonCodec enc;
enc.setPrettyPrint(PPRINT);
auto t = enc.encode(msg);
fprintf(stderr, "MSG: %s\n", t.cStr());
}catch(...){}
}
Where, in this case, msg is:
147 capnp::MallocMessageBuilder builder;
148 auto msg = builder.initRoot<Message>();
//Fill it
254 dump_msg(msg);
So the builder and encoder al valid, I believe in the entire dumping.
Moreover, valgrind would complain before the SEGFAULT if something would be
out of the stack, and the only thing I get is the direct SEGFAULT.
Any thoughts? I will keep trying to isolate the problem
marc
-Kenton
>
> On Fri, Mar 2, 2018 at 10:18 AM, Marc Sune <[email protected]
> <javascript:>> wrote:
>
>> > That's about all that I can get, even though capnproto is compiled with
>> DEBUG.
>>
>> Or shall I say, it should :/
>>
>>
>> On Friday, March 2, 2018 at 7:17:02 PM UTC+1, Marc Sune wrote:
>>>
>>> Hi guys,
>>>
>>> I am experiencing a _very_ strange segfault during JSON encoding of
>>> message:
>>>
>>> ```
>>> Program received signal SIGSEGV, Segmentation fault.
>>> [Switching to Thread 27946]
>>> 0x0000000001e4b81a in std::__detail::_Hashtable_ebo_helper<1,
>>> capnp::(anonymous namespace)::TypeHash,
>>> true>::_S_cget(std::__detail::_Hashtable_ebo_helper<1, capnp::(anonymous
>>> namespace)::TypeHash, true> const&) ()
>>> (gdb) bt
>>> #0 0x0000000001e4b81a in std::__detail::_Hashtable_ebo_helper<1,
>>> capnp::(anonymous namespace)::TypeHash,
>>> true>::_S_cget(std::__detail::_Hashtable_ebo_helper<1, capnp::(anonymous
>>> namespace)::TypeHash, true> const&) ()
>>> #1 0x0000000001e4b11a in std::__detail::_Hash_code_base<capnp::Type,
>>> std::pair<capnp::Type const, capnp::JsonCodec::HandlerBase*>,
>>> std::__detail::_Select1st, capnp::(anonymous namespace)::TypeHash,
>>> std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
>>> true>::_M_h1() const ()
>>> #2 0x0000000001e4a976 in std::__detail::_Hash_code_base<capnp::Type,
>>> std::pair<capnp::Type const, capnp::JsonCodec::HandlerBase*>,
>>> std::__detail::_Select1st, capnp::(anonymous namespace)::TypeHash,
>>> std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
>>> true>::_M_hash_code(capnp::Type const&) const ()
>>> #3 0x0000000001e4a401 in std::_Hashtable<capnp::Type,
>>> std::pair<capnp::Type const, capnp::JsonCodec::HandlerBase*>,
>>> std::allocator<std::pair<capnp::Type const, capnp::JsonCodec::HandlerBase*>
>>> >, std::__detail::_Select1st, std::equal_to<capnp::Type>, capnp::(anonymous
>>> namespace)::TypeHash, std::__detail::_Mod_range_hashing,
>>> std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy,
>>> std::__detail::_Hashtable_traits<true, false, true> >::find(capnp::Type
>>> const&) const ()
>>> #4 0x0000000001e483a3 in std::unordered_map<capnp::Type,
>>> capnp::JsonCodec::HandlerBase*, capnp::(anonymous namespace)::TypeHash,
>>> std::equal_to<capnp::Type>, std::allocator<std::pair<capnp::Type const,
>>> capnp::JsonCodec::HandlerBase*> > >::find(capnp::Type const&) const ()
>>> #5 0x0000000001e443d5 in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type,
>>> capnp::JsonValue::Builder) const ()
>>> #6 0x0000000001e44a6f in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type,
>>> capnp::JsonValue::Builder) const ()
>>> #7 0x0000000001e45a36 in
>>> capnp::JsonCodec::encodeField(capnp::StructSchema::Field,
>>> capnp::DynamicValue::Reader, capnp::JsonValue::Builder) const ()
>>> #8 0x0000000001e45377 in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type,
>>> capnp::JsonValue::Builder) const ()
>>> #9 0x0000000001e45a36 in
>>> capnp::JsonCodec::encodeField(capnp::StructSchema::Field,
>>> capnp::DynamicValue::Reader, capnp::JsonValue::Builder) const ()
>>> #10 0x0000000001e45377 in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type,
>>> capnp::JsonValue::Builder) const ()
>>> #11 0x0000000001e45a36 in
>>> capnp::JsonCodec::encodeField(capnp::StructSchema::Field,
>>> capnp::DynamicValue::Reader, capnp::JsonValue::Builder) const ()
>>> #12 0x0000000001e45377 in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type,
>>> capnp::JsonValue::Builder) const ()
>>> #13 0x0000000001e45a36 in
>>> capnp::JsonCodec::encodeField(capnp::StructSchema::Field,
>>> capnp::DynamicValue::Reader, capnp::JsonValue::Builder) const ()
>>> #14 0x0000000001e45618 in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type,
>>> capnp::JsonValue::Builder) const ()
>>> #15 0x0000000001e45a36 in
>>> capnp::JsonCodec::encodeField(capnp::StructSchema::Field,
>>> capnp::DynamicValue::Reader, capnp::JsonValue::Builder) const ()
>>> #16 0x0000000001e45618 in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type,
>>> capnp::JsonValue::Builder) const ()
>>> #17 0x0000000001e43fcc in
>>> capnp::JsonCodec::encode(capnp::DynamicValue::Reader, capnp::Type) const ()
>>> #18 0x00000000009e02c7 in capnp::JsonCodec::encode<Message::Builder
>>> const&> (this=0x7ffff22e1210, value=...) at
>>> /home/marc/.../capnp/compat/json.h:216
>>> ```
>>>
>>> That's about all that I can get, even though capnproto is compiled with
>>> DEBUG.
>>>
>>> The message trying to be encoded (sorry, I am not sure I can share the
>>> entire set of schemas), is a series of simple objects, which in the
>>> inner-most object contains a list that is initialized normally:
>>>
>>> 115 s.initIfaceType(1);
>>>
>>> The funny part; not initializing it, doesn't make JsonCodec crash. But
>>> initializing it, or initializing it + setting a value (valid one), produces
>>> the crash always.
>>>
>>> Valgrind etc... doesn't complain until that point.
>>>
>>> I am trying to isolate the problem, to make it reproducible, but I am
>>> not able yet.
>>>
>>> Any ideas on this?
>>>
>>> Thanks
>>>
>> --
>> 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 [email protected] <javascript:>.
>> Visit this group at https://groups.google.com/group/capnproto.
>>
>
>
--
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 [email protected].
Visit this group at https://groups.google.com/group/capnproto.