Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coredump when calls MessageToJsonString() #9417

Closed
sin-zx opened this issue Jan 18, 2022 · 2 comments
Closed

coredump when calls MessageToJsonString() #9417

sin-zx opened this issue Jan 18, 2022 · 2 comments

Comments

@sin-zx
Copy link

sin-zx commented Jan 18, 2022

What version of protobuf and what language are you using?
Version: 3.11.2
Language: C++

What operating system (Linux, Windows, ...) and version?
ubuntu18.04
What runtime / compiler are you using (e.g., python version or gcc version)
g++ (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0

What did you do?
here is my code:
图片
I just convert ProtobufMsg to json string, but it will make coredump with a small probability.Here is gdb message:


(gdb) bt
#0 0x00007ffbeed2e0b1 in ?? () from /root/map/lib/libc.so.6
#1 0x00007ffbeed303cd in malloc () from /root/map/lib/libc.so.6
#2 0x00007ffbef335298 in operator new(unsigned long) () from /root/map/lib/libstdc++.so.6
#3 0x00007ffbeac344fb in google::protobuf::util::converter::DefaultValueObjectWriter::CreateNewNode(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, google::protobuf::Type const*, google::protobuf::util::converter::DefaultValueObjectWriter::NodeKind, google::protobuf::util::converter::DataPiece const&, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > const&, bool, bool, bool, std::function<bool (std::vector<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > const&, google::protobuf::Field const*)>) ()
from /root/map/lib/libprotobuf.so.3.11.2.0
#4 0x00007ffbeac3618a in google::protobuf::util::converter::DefaultValueObjectWriter::StartObject(google::protobuf::StringPiece) ()
from /root/map/lib/libprotobuf.so.3.11.2.0
#5 0x00007ffbeac54689 in google::protobuf::util::converter::ProtoStreamObjectSource::WriteMessage(google::protobuf::Type const&, google::protobuf::StringPiece, unsigned int, bool, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#6 0x00007ffbeac596eb in google::protobuf::util::converter::ProtoStreamObjectSource::RenderField(google::protobuf::Field const*, google::protobuf::StringPiece, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#7 0x00007ffbeac54f7c in google::protobuf::util::converter::ProtoStreamObjectSource::RenderList(google::protobuf::Field const*, google::protobuf::StringPiece, unsigned int, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#8 0x00007ffbeac54a34 in google::protobuf::util::converter::ProtoStreamObjectSource::WriteMessage(google::protobuf::Type const&, google::protobuf::StringPiece, unsigned int, bool, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#9 0x00007ffbeac596eb in google::protobuf::util::converter::ProtoStreamObjectSource::RenderField(google::protobuf::Field const*, google::protobuf::StringPiece, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#10 0x00007ffbeac54f7c in google::protobuf::util::converter::ProtoStreamObjectSource::RenderList(google::protobuf::Field const*, google::protobuf::StringPiece, unsigned int, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#11 0x00007ffbeac54a34 in google::protobuf::util::converter::ProtoStreamObjectSource::WriteMessage(google::protobuf::Type const&, google::protobuf::StringPiece, unsigned int, bool, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#12 0x00007ffbeac543ac in google::protobuf::util::converter::ProtoStreamObjectSource::NamedWriteTo(google::protobuf::StringPiece, google::protobuf::util::converter::ObjectWriter*) const () from /root/map/lib/libprotobuf.so.3.11.2.0
#13 0x00007ffbeac5b34e in google::protobuf::util::converter::ObjectSource::WriteTo(google::protobuf::util::converter::ObjectWriter*) const ()
from /root/map/lib/libprotobuf.so.3.11.2.0
#14 0x00007ffbeac74286 in google::protobuf::util::BinaryToJsonStream(google::protobuf::util::TypeResolver*, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, google::protobuf::io::ZeroCopyInputStream*, google::protobuf::io::ZeroCopyOutputStream*, google::protobuf::util::JsonPrintOptions const&)
() from /root/map/lib/libprotobuf.so.3.11.2.0
#15 0x00007ffbeac7445f in google::protobuf::util::BinaryToJsonString(google::protobuf::util::TypeResolver*, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, google::protobuf::util::JsonPrintOptions const&) () from /root/map/lib/libprotobuf.so.3.11.2.0
#16 0x00007ffbeac75629 in google::protobuf::util::MessageToJsonString(google::protobuf::Message const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >
, google::protobuf::util::JsonPrintOptions const&) () from /root/map/lib/libprotobuf.so.3.11.2.0
#17 0x00007ffbee6ff736 in drrun::ProtocolConversion::ProtobufToJsonStr (msg=..., enum_to_str=true, pb2json_str=0x7ffbabffe9b0)
at /builds/deeproute/DrRun/common/protocol_conversion/protocol_conversion.cpp:17
#18 0x00007ffbf0a1230c in drrun::common::DealWithHttpRq<std::_Bind<void (drrun::map_service::MapLogicWraper::(drrun::map_service::MapLogicWraper, std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(drrun::common::proto::DecodeAccessJWT const&, drrun::map_service::proto::GetRouteRQ const&, drrun::map_service::proto::GetRouteRP*)>, drrun::map_service::proto::GetRouteRQ, drrun::map_service::proto::GetRouteRP>(std::_Bind<void (drrun::map_service::MapLogicWraper::(drrun::map_service::MapLogicWraper, std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(drrun::common::proto::DecodeAccessJWT const&, drrun::map_service::proto::GetRouteRQ const&, drrun::map_service::proto::GetRouteRP*)> const&, std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_serviceboost::asio::ip::tcp > >::Request>, std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_serviceboost::asio::ip::tcp > >::Response>, drrun::map_service::proto::GetRouteRQ*, drrun::map_service::proto::GetRouteRP*, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) (function=..., request=..., response=..., rq=0x7ffbabffea70, rsp=0x7ffbabffeaa0, jwt=...)
at /builds/deeproute/DrRun/common/utils/utils.hpp:257


Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

What did you expect to see

What did you see instead?
core dump
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment
My program runs in docker.

@sin-zx
Copy link
Author

sin-zx commented Jan 18, 2022

My proto just like:
syntax="proto3"; message RP { drrun.common.proto.ErrorCode error_code = 1; repeated PolylineLLH routes = 2; repeated double duration = 3; repeated double distance = 4; }

@fowles
Copy link
Contributor

fowles commented Jan 18, 2022

An intermittent core dump like this is far more likely to be a race condition or use after free bug in the surrounding code, so I am going to have to close this. If you can reproduce this with a recent version of protobuf and can provide actual steps to produce there error (even if it only occurs 1/1000 times), feel free to reopen with that additional information.

@fowles fowles closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants