protobuf throws setting a required field

16 views
Skip to first unread message

shailesh durgapal

unread,
Oct 22, 2020, 9:31:31 PM10/22/20
to Protocol Buffers
Hello
I am using protobuf v2 for many years.
Recently I had to add a new required string attribute to the existing message.
Everything compiles and builds using centos 7.
But the set method throws from inside the libstdc when doing the assign.
(gdb) bt
#0 0x00007f5c07d9ad39 in std::string::assign(std::string const&) () from 
lib64/libstdc++.so.6
#1 0x00007f5c16232b2a in set_serverid (value=3D"fb07a762-5ffd-41c2-b6b3-f2=
3d0e26ad91", this=3D0x8d2db30)
at /usr/include/.../.../common/Messages.pb.h:11358

Line 11358 is:
inline void Info::set_serverid(const ::std::string& value) {
  set_has_serverid();
  if (serverid_ == &::google::protobuf::internal::kEmptyString) {
    serverid_ = new ::std::string;
  }
  serverid_->assign(value);
}

I set it as:
// ... existing required fields
m_lnfo.set_serverid(m_ServerId); // new field to be added
DEBUG_MSG( "protobuf is initialized: " << m_Info.IsInitialized());

If I do not set the serverid field, then the next line says that protobuf msg m_Info 
is NOT initialized.
I must be missing something. Does anybody have any ideas? Appreciate any reponses.
thanks
shailesh
Reply all
Reply to author
Forward
0 new messages