Pyroot failed to process google protobuf code while root prompt works fine


ROOT Version: 6.16/00
Platform: linuxx8664gcc
Compiler: GCC 7.2.0
Python: 3.6.5
Google Protobuf:_ 3.6.1


so i am able to use rootcling to create LinkDef and create the share lib with a bunch of google protobuf generated headers. and i can use the protobuf generated shared lib in root prompt w/o issue (while not really, i have to manually add some template class specification into the so file, but that’s another story, if anybody is interested i can share the solution.) , for example:

root [0] .L has_bits-ni.so // this is to load my template specifications.
root [1] .L Loader-_sw_gsd_PBTypes_linux64_13.1.0_include_ctc_core_common_LinkDef.C // load protobufs
root [3] ctc::core::common::Name n  // create one of the protobuf msg type
(ctc::core::common::Name &) @0x7f7b01609050
root [4] n.set_name(
void set_name(const char* value)
void set_name(const char* value, size_t size)
void set_name(const string& value)
void set_name(string&& value)
root [4] n.set_name("aName")  // test setter
root [5] n.name()  // test getter
(const std::string &) "aName"
root [6] ctc::core::common::NameVector nv  // create a protobuf msg with repeated field.
(ctc::core::common::NameVector &) @0x7f7b01609070
root [7] nv.mutable_
mutable_unknown_fields
mutable_vector
root [7] nv.mutable_vector
mutable_vector
root [7] nv.mutable_vector(
ctc::core::common::Name* mutable_vector(int index)
google::protobuf::RepeatedPtrField<ctc::core::common::Name>* mutable_vector()
root [7] nv.add_vector(
ctc::core::common::Name* add_vector()
root [7] auto np = nv.add_vector()
(ctc::core::common::Name *) @0x7fff8e867c50
root [8] np->set_name("name 1")
root [9]  np = nv.add_vector()
(ctc::core::common::Name *) @0x7fff8e867c40
root [10] np->set_name("name 2")
root [11] nv.vector_size()
(int) 2
root [14] nv.vector
vector
vector_size
root [14] nv.vector(0)
(const ctc::core::common::Name &) @0x550e760
root [15] nv.vector(0).name()
(const std::string &) "name 1"
root [16] nv.vector(1).name()
(const std::string &) "name 2"

however if i run the thing in python, it failed miserably, RIP = ROOT.gInterpreter.ProcessLine:

>>> RIP('.L has_bits-ni.so')
0
>>> RIP('.L Loader-_sw_gsd_PBTypes_linux64_13.1.0_include_ctc_core_common_LinkDef.C')
140222245543984
>>>
>>> RIP('ctc::core::common::Bool ab; ab.set_value(true); ab')
(ctc::core::common::Bool &) @0x7f880922a040
140222245544000
>>> ROOT.ab.value()
True
# so far so good.
>>> ROOT.gInterpreter.ProcessLine('ctc::core::common::Name n1;')
140222245544032
>>> ROOT.n1
<ROOT.ctc::core::common::Name object at 0x7f880922a060>
>>> ROOT.n1.has_name()
False
>>> ROOT.gInterpreter.ProcessLine('n1.set_name("test me"); n1')

 *** Break *** segmentation violation




===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================

Thread 2 (Thread 0x7f87f05f4700 (LWP 10997)):
#0  0x00007f8808943a0e in pthread_cond_timedwait

GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f8808e79c83 in PyEval_RestoreThread ()
#2  0x00007f8808f66a5c in time_sleep ()
#3  0x00007f8808e85b55 in _PyCFunction_FastCallDict ()
#4  0x00007f8808f1567c in call_function ()
#5  0x00007f8808f37cba in _PyEval_EvalFrameDefault ()
#6  0x00007f8808f10459 in PyEval_EvalCodeEx ()
#7  0x00007f8808f11376 in function_call ()
#8  0x00007f8808e8599e in PyObject_Call ()
#9  0x00007f8808f39470 in _PyEval_EvalFrameDefault ()
#10 0x00007f8808f0f70b in fast_function ()
#11 0x00007f8808f15755 in call_function ()
#12 0x00007f8808f37cba in _PyEval_EvalFrameDefault ()
#13 0x00007f8808f0f70b in fast_function ()
#14 0x00007f8808f15755 in call_function ()
#15 0x00007f8808f37cba in _PyEval_EvalFrameDefault ()
#16 0x00007f8808f0fd7b in _PyFunction_FastCallDict ()
#17 0x00007f8808e85f5f in _PyObject_FastCallDict ()
#18 0x00007f8808e8aa03 in _PyObject_Call_Prepend ()
#19 0x00007f8808e8599e in PyObject_Call ()
#20 0x00007f8808f85b56 in t_bootstrap ()
#21 0x00007f880893fa51 in start_thread () from /lib64/libpthread.so.0
#22 0x00007f880868c9ad in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f8809221700 (LWP 10977)):
#0  0x00007f880865070d in waitpid () from /lib64/libc.so.6
#1  0x00007f88085e2609 in do_system () from /lib64/libc.so.6
#2  0x00007f88085e2940 in system () from /lib64/libc.so.6
#3  0x00007f87ff3a9403 in TUnixSystem::Exec (shellcmd=<optimized out>, this=0x7f88094c8f30) at /home/dongh/shome/hackweek/ROOT/root/core/unix/src/TUnixSystem.cxx:2119
#4  TUnixSystem::StackTrace (this=0x7f88094c8f30) at /home/dongh/shome/hackweek/ROOT/root/core/unix/src/TUnixSystem.cxx:2413
#5  0x00007f87ff3ab9b7 in TUnixSystem::DispatchSignals (this=0x7f88094c8f30, sig=kSigSegmentationViolation) at /home/dongh/shome/hackweek/ROOT/root/core/unix/src/TUnixSystem.cxx:3644
#6  <signal handler called>
#7  0x00007f87fbe13be0 in clang::Decl::castFromDeclContext(clang::DeclContext const*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#8  0x00007f87fa41f122 in (anonymous namespace)::ItaniumCXXABI::NeedsVTTParameter(clang::GlobalDecl) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#9  0x00007f87fa49cfa8 in clang::CodeGen::CodeGenFunction::GetVTTParameter(clang::GlobalDecl, bool, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#10 0x00007f87fa427638 in (anonymous namespace)::ItaniumCXXABI::EmitDestructorCall(clang::CodeGen::CodeGenFunction&, clang::CXXDestructorDecl const*, clang::CXXDtorType, bool, bool, clang::CodeGen::Address) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#11 0x00007f87fa495177 in clang::CodeGen::CodeGenFunction::destroyCXXObject(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#12 0x00007f87fa4b4750 in clang::CodeGen::CodeGenFunction::emitDestroy(clang::CodeGen::Address, clang::QualType, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#13 0x00007f87fa4b4add in clang::CodeGen::EHScopeStack::ConditionalCleanup<(anonymous namespace)::DestroyObject, clang::CodeGen::Address, clang::QualType, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool>::Emit(clang::CodeGen::CodeGenFunction&, clang::CodeGen::EHScopeStack::Cleanup::Flags) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#14 0x00007f87fa4a2b6a in EmitCleanup(clang::CodeGen::CodeGenFunction&, clang::CodeGen::EHScopeStack::Cleanup*, clang::CodeGen::EHScopeStack::Cleanup::Flags, clang::CodeGen::Address) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#15 0x00007f87fa4a6d42 in clang::CodeGen::CodeGenFunction::PopCleanupBlock(bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#16 0x00007f87fa4a7291 in clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator, std::initializer_list<llvm::Value**>) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#17 0x00007f87fa4a768c in clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator, unsigned long, std::initializer_list<llvm::Value**>) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#18 0x00007f87fa36f8e6 in clang::CodeGen::CodeGenFunction::EmitWhileStmt(clang::WhileStmt const&, llvm::ArrayRef<clang::Attr const*>) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#19 0x00007f87fa36e70f in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#20 0x00007f87fa36eb52 in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#21 0x00007f87fa3a6ae7 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#22 0x00007f87fa3c210f in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#23 0x00007f87fa3e2332 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#24 0x00007f87fa3e2435 in clang::CodeGen::CodeGenModule::EmitDeferred() () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#25 0x00007f87fa3e24f1 in clang::CodeGen::CodeGenModule::Release() () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#26 0x00007f87fa330bab in clang::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#27 0x00007f87fa28b7cf in cling::IncrementalParser::codeGenTransaction(cling::Transaction*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#28 0x00007f87fa28bb2b in cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm
::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*> > >&, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#29 0x00007f87fa28bd3a in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#30 0x00007f87fa21ee11 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#31 0x00007f87fa21f62d in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#32 0x00007f87fa2cb348 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#33 0x00007f87fa17f8fc in HandleInterpreterException (metaProcessor=0x7f88095ea6c0, input_line=<optimized out>, compRes=
0x7ffcfad977b4: cling::Interpreter::kSuccess, result=result
entry=0x7ffcfad978e0) at /home/dongh/shome/hackweek/ROOT/root/core/metacling/src/TCling.cxx:2163
#34 0x00007f87fa192f86 in TCling::ProcessLine (this=0x7f880958f5f0, line=<optimized out>, error=0x0) at /home/dongh/shome/hackweek/ROOT/root/core/metacling/src/TCling.cxx:2321
#35 0x00007f8808c22059 in ?? ()
#36 0x00007f87d34348f0 in ?? ()
#37 0x00007ffcfad97ba0 in ?? ()
#38 0x00007ffcfad97b80 in ?? ()
#39 0x00007f88085ccbfd in setlocale () from /lib64/libc.so.6
#40 0x00007f87f0a76ca0 in ?? ()
#41 0x0000007f00000001 in ?? ()
#42 0x0000000000000000 in ?? ()
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#7  0x00007f87fbe13be0 in clang::Decl::castFromDeclContext(clang::DeclContext const*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#8  0x00007f87fa41f122 in (anonymous namespace)::ItaniumCXXABI::NeedsVTTParameter(clang::GlobalDecl) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#9  0x00007f87fa49cfa8 in clang::CodeGen::CodeGenFunction::GetVTTParameter(clang::GlobalDecl, bool, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#10 0x00007f87fa427638 in (anonymous namespace)::ItaniumCXXABI::EmitDestructorCall(clang::CodeGen::CodeGenFunction&, clang::CXXDestructorDecl const*, clang::CXXDtorType, bool, bool, clang::CodeGen::Address) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#11 0x00007f87fa495177 in clang::CodeGen::CodeGenFunction::destroyCXXObject(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#12 0x00007f87fa4b4750 in clang::CodeGen::CodeGenFunction::emitDestroy(clang::CodeGen::Address, clang::QualType, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#13 0x00007f87fa4b4add in clang::CodeGen::EHScopeStack::ConditionalCleanup<(anonymous namespace)::DestroyObject, clang::CodeGen::Address, clang::QualType, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool>::Emit(clang::CodeGen::CodeGenFunction&, clang::CodeGen::EHScopeStack::Cleanup::Flags) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#14 0x00007f87fa4a2b6a in EmitCleanup(clang::CodeGen::CodeGenFunction&, clang::CodeGen::EHScopeStack::Cleanup*, clang::CodeGen::EHScopeStack::Cleanup::Flags, clang::CodeGen::Address) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#15 0x00007f87fa4a6d42 in clang::CodeGen::CodeGenFunction::PopCleanupBlock(bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#16 0x00007f87fa4a7291 in clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator, std::initializer_list<llvm::Value**>) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#17 0x00007f87fa4a768c in clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator, unsigned long, std::initializer_list<llvm::Value**>) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#18 0x00007f87fa36f8e6 in clang::CodeGen::CodeGenFunction::EmitWhileStmt(clang::WhileStmt const&, llvm::ArrayRef<clang::Attr const*>) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#19 0x00007f87fa36e70f in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#20 0x00007f87fa36eb52 in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#21 0x00007f87fa3a6ae7 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#22 0x00007f87fa3c210f in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#23 0x00007f87fa3e2332 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#24 0x00007f87fa3e2435 in clang::CodeGen::CodeGenModule::EmitDeferred() () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#25 0x00007f87fa3e24f1 in clang::CodeGen::CodeGenModule::Release() () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#26 0x00007f87fa330bab in clang::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#27 0x00007f87fa28b7cf in cling::IncrementalParser::codeGenTransaction(cling::Transaction*) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#28 0x00007f87fa28bb2b in cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*> > >&, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#29 0x00007f87fa28bd3a in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#30 0x00007f87fa21ee11 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#31 0x00007f87fa21f62d in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#32 0x00007f87fa2cb348 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/dongh/pkg/usr/local/root/lib/libCling.so
#33 0x00007f87fa17f8fc in HandleInterpreterException (metaProcessor=0x7f88095ea6c0, input_line=<optimized out>, compRes=
0x7ffcfad977b4: cling::Interpreter::kSuccess, result=result
entry=0x7ffcfad978e0) at /home/dongh/shome/hackweek/ROOT/root/core/metacling/src/TCling.cxx:2163
#34 0x00007f87fa192f86 in TCling::ProcessLine (this=0x7f880958f5f0, line=<optimized out>, error=0x0) at /home/dongh/shome/hackweek/ROOT/root/core/metacling/src/TCling.cxx:2321
#35 0x00007f8808c22059 in ?? ()
#36 0x00007f87d34348f0 in ?? ()
#37 0x00007ffcfad97ba0 in ?? ()
#38 0x00007ffcfad97b80 in ?? ()
#39 0x00007f88085ccbfd in setlocale () from /lib64/libc.so.6
#40 0x00007f87f0a76ca0 in ?? ()
#41 0x0000007f00000001 in ?? ()
#42 0x0000000000000000 in ?? ()
===========================================================


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: long TInterpreter::ProcessLine(const char* line, TInterpreter::EErrorCode* error = 0) =>
    problem in C++; program state has been reset

so my question is, what happened to pyroot to cause it to fail? is there a way to make it work?

HI @hsd

If in your example, instead of

>>> ROOT.gInterpreter.ProcessLine('n1.set_name("test me"); n1')

you do

>>> ROOT.n1.set_name("test me")
>>> ROOT.n1.name()

does it also crash?

Yes it will crash with the same stack trace. that’s why i was hoping to be able to use process line to work around the issue.

I can’t tell from the clang stack trace what is going on, perhaps @Axel ?

When is exactly the error triggered? When you run

ROOT.n1.set_name("test me")

or

>>> ROOT.n1.name()

?

You’re asking the right questions, @etejedor :slight_smile: I can’t tell either; I’d need to debug to see which declaration this is failing on.

(It’s a missing cling feature; I really want to have an error message on every invalid Decl before running CodeGen, and I bet this crash is caused by one.)

it crashed from

ROOT.n1.set_name('test me')

ROOT.n1.name() works fine. it will returns an empty str.

Can you point me to the doc of set_name?

below is the class defined in the header Name.pb.h, the set_name is also defined as inline in the header. and i am using defined_in Named.pb.h in my linkdef.h to generate the dict:
i am wondering if the pyroot is calling into the set_name differently than than cling?

// ===================================================================

class Name : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:ctc.core.common.Name) */ {
 public:
  Name();
  virtual ~Name();

  Name(const Name& from);

  inline Name& operator=(const Name& from) {
    CopyFrom(from);
    return *this;
  }
  #if LANG_CXX11
  Name(Name&& from) noexcept
    : Name() {
    *this = ::std::move(from);
  }

  inline Name& operator=(Name&& from) noexcept {
    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
      if (this != &from) InternalSwap(&from);
    } else {
      CopyFrom(from);
    }
    return *this;
  }
  #endif
  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
    return _internal_metadata_.unknown_fields();
  }
  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
    return _internal_metadata_.mutable_unknown_fields();
  }

  static const ::google::protobuf::Descriptor* descriptor();
  static const Name& default_instance();

  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
  static inline const Name* internal_default_instance() {
    return reinterpret_cast<const Name*>(
               &_Name_default_instance_);
  }
  static constexpr int kIndexInFileMessages =
    0;

  void Swap(Name* other);
  friend void swap(Name& a, Name& b) {
    a.Swap(&b);
  }

  // implements Message ----------------------------------------------

  inline Name* New() const final {
    return CreateMaybeMessage<Name>(NULL);
  }

  Name* New(::google::protobuf::Arena* arena) const final {
    return CreateMaybeMessage<Name>(arena);
  }
  void CopyFrom(const ::google::protobuf::Message& from) final;
  void MergeFrom(const ::google::protobuf::Message& from) final;
  void CopyFrom(const Name& from);
  void MergeFrom(const Name& from);
  void Clear() final;
  bool IsInitialized() const final;

  size_t ByteSizeLong() const final;
  bool MergePartialFromCodedStream(
      ::google::protobuf::io::CodedInputStream* input) final;
  void SerializeWithCachedSizes(
      ::google::protobuf::io::CodedOutputStream* output) const final;
  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
      bool deterministic, ::google::protobuf::uint8* target) const final;
  int GetCachedSize() const final { return _cached_size_.Get(); }

  private:
  void SharedCtor();
  void SharedDtor();
  void SetCachedSize(int size) const final;
  void InternalSwap(Name* other);
  private:
  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
    return NULL;
  }
  inline void* MaybeArenaPtr() const {
    return NULL;
  }
  public:

  ::google::protobuf::Metadata GetMetadata() const final;

  // nested types ----------------------------------------------------

  // accessors -------------------------------------------------------

  // optional string name = 1;
  bool has_name() const;
  void clear_name();
  static const int kNameFieldNumber = 1;
  const ::std::string& name() const;
  void set_name(const ::std::string& value);
  #if LANG_CXX11
  void set_name(::std::string&& value);
  #endif
  void set_name(const char* value);
  void set_name(const char* value, size_t size);
  ::std::string* mutable_name();
  ::std::string* release_name();
  void set_allocated_name(::std::string* name);

  // @@protoc_insertion_point(class_scope:ctc.core.common.Name)
 private:
  void set_has_name();
  void clear_has_name();

  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  ::google::protobuf::internal::HasBits<1> _has_bits_;
  mutable ::google::protobuf::internal::CachedSize _cached_size_;
  ::google::protobuf::internal::ArenaStringPtr name_;
  friend struct ::protobuf_ctc_2fcore_2fcommon_2fName_2eproto::TableStruct;
};

// -------------------------------------------------------------------
inline void Name::set_name(const ::std::string& value) {
  set_has_name();
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
  // @@protoc_insertion_point(field_set:ctc.core.common.Name.name)
}
#if LANG_CXX11
inline void Name::set_name(::std::string&& value) {
  set_has_name();
  name_.SetNoArena(
    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
  // @@protoc_insertion_point(field_set_rvalue:ctc.core.common.Name.name)
}
#endif
inline void Name::set_name(const char* value) {
  GOOGLE_DCHECK(value != NULL);
  set_has_name();
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
  // @@protoc_insertion_point(field_set_char:ctc.core.common.Name.name)
}
inline void Name::set_name(const char* value, size_t size) {
  set_has_name();
  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
      ::std::string(reinterpret_cast<const char*>(value), size));
  // @@protoc_insertion_point(field_set_pointer:ctc.core.common.Name.name)
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

I don’t manage to parse your header:

   size_t ByteSizeLong() const final;
                               ^~~~~

My protobuf doesn’t have any HasBits either. I added the following lines at the beginning of your file:

#include "google/protobuf/message.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/metadata.h"

What am I doing wrong?

Cheers, Axel.