Segmentation fault

824 views
Skip to first unread message

Xuanting Cai

unread,
Apr 1, 2017, 5:36:06 PM4/1/17
to Protocol Buffers
Hi 

I am running some very simple code, but I got Segmentation fault.
I compiled it with bazel and some proto complie library for bazel.

Here is my code in .cc file

string ToString(const Message& message) {
TextFormat::Printer printer;
  printer.SetSingleLineMode(true);
  
  string proto_in_line_string;
  printer.PrintToString(message, &proto_in_line_string);
  
  return proto_in_line_string;
}

Here is my code in test.cc file

struct ProtoHelperFixture {};

BOOST_FIXTURE_TEST_SUITE(ProtoHelperTests, ProtoHelperFixture)

BOOST_AUTO_TEST_CASE(ToStringTest) {
TimeInterval time_interval;
TextFormat::ParseFromString(
R"(begin_time: "2017-01-01 10:00:00")"
R"(end_time: "2017-01-01 10:30:00")",
&time_interval);
LOG(INFO) << ToString(time_interval);
}

BOOST_AUTO_TEST_SUITE_END()

Run it in gdb, I got

#0  0x0000002965707954 in ?? ()
#1  0x00007ffff7f2da5d in google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned long) ()
   from /home/caixuanting/.cache/bazel/_bazel_caixuanting/6f27b1af69abf374829e79d372f6b04b/execroot/myth-trading-system/bazel-out/local-opt/bin/utils/../_solib_k8/libexternal_Scom_Ugithub_Ugoogle_Uprotobuf_Slibprotobuf_Ulite.so
#2  0x00007ffff7f2da92 in google::protobuf::Arena::AddListNode(void*, void (*)(void*)) ()
   from /home/caixuanting/.cache/bazel/_bazel_caixuanting/6f27b1af69abf374829e79d372f6b04b/execroot/myth-trading-system/bazel-out/local-opt/bin/utils/../_solib_k8/libexternal_Scom_Ugithub_Ugoogle_Uprotobuf_Slibprotobuf_Ulite.so
#3  0x00007ffff7cc23ef in google::protobuf::FileDescriptorProto::New(google::protobuf::Arena*) const ()
   from /home/caixuanting/.cache/bazel/_bazel_caixuanting/6f27b1af69abf374829e79d372f6b04b/execroot/myth-trading-system/bazel-out/local-opt/bin/utils/../_solib_k8/libexternal_Scom_Ugithub_Ugoogle_Uprotobuf_Slibprotobuf.so
#4  0x00007ffff7270acb in google::protobuf::MessageLite::ParseFromArray(void const*, int) ()
   from /usr/lib/x86_64-linux-gnu/libprotobuf.so.8
#5  0x00007ffff72b30f3 in google::protobuf::EncodedDescriptorDatabase::Add(void const*, int) ()
   from /usr/lib/x86_64-linux-gnu/libprotobuf.so.8
#6  0x00007ffff727a40a in google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*, int) () from /usr/lib/x86_64-linux-gnu/libprotobuf.so.8
#7  0x00007ffff72ac41c in google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() () from /usr/lib/x86_64-linux-gnu/libprotobuf.so.8
#8  0x00007ffff7dea10a in call_init (l=<optimized out>, argc=argc@entry=1,
    argv=argv@entry=0x7fffffffe428, env=env@entry=0x7fffffffe438) at dl-init.c:78
#9  0x00007ffff7dea1f3 in call_init (env=<optimized out>, argv=<optimized out>,
    argc=<optimized out>, l=<optimized out>) at dl-init.c:36
#10 _dl_init (main_map=0x7ffff7ffe1c8, argc=1, argv=0x7fffffffe428, env=0x7fffffffe438)
    at dl-init.c:126
#11 0x00007ffff7ddb30a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#12 0x0000000000000001 in ?? ()
#13 0x00007fffffffe660 in ?? ()
#14 0x0000000000000000 in ?? ()


Adam Cozzette

unread,
Apr 3, 2017, 4:39:36 PM4/3/17
to Xuanting Cai, Protocol Buffers
What protobuf version are you using? Also, are you linking against a libprotobuf that has the same version as the protoc that was used to generate your code? It's important for the version to match, because for C++ we frequently change the interface between the generated code and the runtime library.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscribe@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Xuanting Cai

unread,
Apr 8, 2017, 2:40:27 AM4/8/17
to Protocol Buffers, caixu...@gmail.com
I am using protoc 3.1.0

# protoc --version
libprotoc 3.1.0

I am building my project with bazel, which load proto build rule from https://github.com/pubref/rules_protobuf.

https://github.com/pubref/rules_protobuf says it support protobuf 3.1.x

It seems the segmentation fault happens at destroy stage.

Thanks.


To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages