0

I'am trying to connect some data from protobuf to json.

This are the relevants parts of my code:

Message* m;
std::string json;
std::string binary_s;
...fill the message...
m->serializeToString(&binary_s);
MessageToJsonString(*m, &json);

The istruction below works fine and produced the expected output.

m->serializeToString(&binary_s); 

But when I try to convert it into json, this error always appear:

Program received signal SIGSEGV, Segmentation fault.
google::protobuf::DescriptorPool::FindFileByName (this=0x0,     name="FLATBUFFER_DEFINITION.proto") at google/protobuf/descriptor.cc:1415
1415      MutexLockMaybe lock(mutex_);
(gdb) backtrace
#0  google::protobuf::DescriptorPool::FindFileByName (this=0x0,     name="AutoPilot.proto")
    at google/protobuf/descriptor.cc:1415
#1  0x00007ffff7aba42d in google::protobuf::internal::AssignDescriptors     (filename="AutoPilot.proto", 
    schemas=0x4463a0 <protobuf_AutoPilot_2eproto::schemas>, 
    default_instances_=0x446500     <protobuf_AutoPilot_2eproto::file_default_instances>, 
    offsets=0x445c20 <protobuf_AutoPilot_2eproto::TableStruct::offsets>, factory=0x0, 
    file_level_metadata=0x665020 <protobuf_AutoPilot_2eproto::file_level_metadata>, 
    file_level_enum_descriptors=0x6651e0 <protobuf_AutoPilot_2eproto::file_level_enum_descriptors>, 
    file_level_service_descriptors=0x0) at google/protobuf    /generated_message_reflection.cc:2316
#2  0x000000000040730c in         protobuf_AutoPilot_2eproto::protobuf_AssignDescriptors() ()
#3  0x00007ffff7a24bd5 in google::protobuf::internal::FunctionClosure0::Run (this=0x7fffffffda90)
    at ./google/protobuf/stubs/callback.h:129
#4  google::protobuf::GoogleOnceInitImpl (
once=0x665388     <protobuf_AutoPilot_2eproto::protobuf_AssignDescriptorsOnce()::once>,     closure=0x7fffffffda90)
    at google/protobuf/stubs/once.cc:83
#5  0x0000000000433abb in google::protobuf::GoogleOnceInit(long*, void     (*)()) ()
#6  0x0000000000407383 in protobuf_AutoPilot_2eproto::protobuf_AssignDescriptorsOnce() ()
#7  0x0000000000431503 in Message::GetMetadata() const ()
#8  0x00007ffff7b536cc in google::protobuf::Message::GetDescriptor (this=0x68e0b0) at ./google/protobuf/message.h:336
#9  google::protobuf::util::MessageToJsonString (message=warning: RTTI     symbol not found for class 'Message'
..., output=0x7fffffffdd60, options=...)
    at google/protobuf/util/json_util.cc:217

It seems like it can't find the file "FLATBUFFER_DEFINITION.proto", but it is in the same directory of the executable.

Franconet
  • 41
  • 1
  • 10

1 Answers1

0
google::protobuf::DescriptorPool::FindFileByName **(**this=0x0**,** name="FLATBUFFER_DEFINITION.proto") at google/protobuf/descriptor.cc:1415
1415      MutexLockMaybe lock(mutex_);

Object pointer is null. I had call ShutdownProtobufLibrary(); and after ,continue using his functions.

Franconet
  • 41
  • 1
  • 10