Hello,
I am attempting to integrate ROOT IO into a Geant4 program, but I’m running into difficulties with how LLVM is being linked which causes some odd runtime errors.
I get seg faults but not all the time. It seems to occur mainly when the Geant4 visualization system is active during a run in an interactive session, but I can run in batch mode okay.
First, I get the following warning message:
Error in UnknownClass::InitInterpreter(): LLVM SYMBOLS ARE EXPOSED TO CLING! This will cause problems; please hide them or dlopen() them after the call to TROOT::InitInterpreter()!
After this, a Seg Fault occurs with a rather complex traceback. The relevant portion of one example is probably the following:
#27 0x00007f96d6cba023 in llvm::MemoryBuffer::getMemBufferRef() const () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#28 0x00007f96d56836e1 in std::_Function_handler<llvm::object::OwningBinaryllvm::object::ObjectFile (llvm::Module&), llvm::SimpleCompiler>::_M_invoke(std::_Any_data const&, llvm::Module&) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#29 0x00007f96d5682cc7 in std::_List_iteratorllvm::ObjectLinkingLayerBase::LinkedObjectSet llvm::IRCompileLayer<llvm::ObjectLinkingLayercling::IncrementalJIT::NotifyObjectLoadedT >::addModuleSet<std::vector<llvm::Module*, std::allocatorllvm::Module* > >(std::vector<llvm::Module*, std::allocatorllvm::Module* >, std::unique_ptr<llvm::RTDyldMemoryManager, std::default_deletellvm::RTDyldMemoryManager >) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#30 0x00007f96d5683553 in llvm::LazyEmittingLayer<llvm::IRCompileLayer<llvm::ObjectLinkingLayercling::IncrementalJIT::NotifyObjectLoadedT > >::EmissionDeferredSetImpl<std::vector<llvm::Module*, std::allocatorllvm::Module* > >::Emit(llvm::IRCompileLayer<llvm::ObjectLinkingLayercling::IncrementalJIT::NotifyObjectLoadedT >&) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#31 0x00007f96d56813ec in cling::IncrementalJIT::getSymbolAddressWithoutMangling(llvm::StringRef, bool) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#32 0x00007f96d567f807 in cling::IncrementalExecutor::runStaticInitializersOnce(cling::Transaction const&) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#33 0x00007f96d5629786 in cling::Interpreter::executeTransaction(cling::Transaction&) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#34 0x00007f96d5686791 in cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraitscling::Transaction* >) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#35 0x00007f96d562bfc8 in cling::Interpreter::Interpreter(int, char const* const*, char const*, bool) () from /u/ey/jeremym/ldmx-dev/root-6.06.06/build/lib/libCling.so
#36 0x00007f96d54d7d91 in TCling::TCling (this=0x33cf9b0, name=0x7f96d6d06a87 “C++”, title=0x7f96d6d06a71 “cling C++ Interpreter”) at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/meta/src/TCling.cxx:1098
#37 0x00007f96d54d4f03 in CreateInterpreter (interpLibHandle=0x1baa2d0) at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/meta/src/TCling.cxx:578
#38 0x00007f96eba0022c in TROOT::InitInterpreter (this=0x7f96ebf06640 ROOT::Internal::GetROOT1()::alloc) at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/base/src/TROOT.cxx:1767
#39 0x00007f96eb9f9e03 in ROOT::Internal::GetROOT2 () at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/base/src/TROOT.cxx:362
#40 0x00007f96eb9f9e2e in ROOT::GetROOT () at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/base/src/TROOT.cxx:376
#41 0x00007f96ebb892b5 in TClass::GetClass (name=0x7f96f215f5c4 “SimParticle”, load=true, silent=false) at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/meta/src/TClass.cxx:2891
#42 0x00007f96ebb44077 in TClonesArray::SetClass (this=0x33e08c0, classname=0x7f96f215f5c4 “SimParticle”, s=100) at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/cont/src/TClonesArray.cxx:721
#43 0x00007f96ebb42461 in TClonesArray::TClonesArray (this=0x33e08c0, classname=0x7f96f215f5c4 “SimParticle”, s=100) at /nfs/slac/g/ldmx/users/jeremym/dev/root-6.06.06/core/cont/src/TClonesArray.cxx:167
Strangely enough, it seems to crash in different places if I rerun it. I assume this error is related to the warning about the LLVM/Cling symbols (though it may in fact not be!).
I read on a few articles I found on Google that linking Cling in explicitly to a binary can cause these types of issues, but I am not doing this. The libCling.so should be loaded dynamically by TROOT (I think?).
I configure ROOT as follows in my CMake file:
find_package(ROOT REQUIRED COMPONENTS Core RIO)
Then I link in the standard way:
target_link_libraries(myprog ${ROOT_LIBRARIES})
Since this is primarily a Geant4 app, I’m using its compiler switches:
include(${Geant4_USE_FILE})
Perhaps I should try ROOT’s instead? (Not sure it would make any difference.)
I am using these packages:
Geant4 10.2.p02
ROOT 6.06.06
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
cmake version 3.6.1
CentOS Linux release 7.2.1511 (Core)
I am running on a Linux VM but I doubt this has anything to do with it.
Any suggestions for what I can try to do in order to debug this?
Is it possible that using a newer, external LLVM instead of the one packaged with ROOT could help solve this problem? I read that the newer LLVM uses versioned symbols which might help.
Is there an example of a known working CMakeLists.txt which configures both Geant4 and ROOT correctly so they both work without crashing? Specifically, I need to be able to have an active Geant4 visualization like OpenGL in an interactive session for showing an event display without these crashes.
Thanks.
–Jeremy