__dso_handle runtime error on RHEL 6.1

I downloaded and built llvm, clang, and cling today following the instructions (and pulled the last known good revision of llvm). It compiled, but I am getting the following upon executing cling:

LLVM ERROR: Could not resolve external global address: __dso_handle

If I hack llvm and force HAVE_DSO_HANDLE, it works, but cling crashes whenever an error is encountered. This is my exact change to llvm:

[code]Index: lib/ExecutionEngine/JIT/JIT.cpp

— lib/ExecutionEngine/JIT/JIT.cpp (revision 165095)
+++ lib/ExecutionEngine/JIT/JIT.cpp (working copy)
@@ -52,6 +52,7 @@

endif

#endif

+#define HAVE___DSO_HANDLE 1
#if HAVE___DSO_HANDLE
extern void *__dso_handle attribute ((visibility (“hidden”)));
#endif[/code]

Any suggestions?


Jeremy

Hi,
On what platform you are seeing the problem?
Vassil

Red Hat Enterprise Linux 6.1

Can you post the stack trace of the crash?

It’s not a crash, the error condition is handled within llvm and prints the message I first posted. This is the line it happens on in llvm:

llvm.org/docs/doxygen/html/JIT_8 … tml#l00760

Hmm, I suppose I could make it break there and then print the stack – I’ll try that.

[quote=“jcowles”]
If I hack llvm and force HAVE_DSO_HANDLE, it works, but cling crashes whenever an error is encountered. [/quote]
I meant the stack trace from the crash in cling.
Vassil

Ah, sorry, there are a couple actually, here you go:

#6 <signal handler called> #7 0x00007f3ac2edba45 in raise () from /lib64/libc.so.6 #8 0x00007f3ac2edd225 in abort () from /lib64/libc.so.6 #9 0x00007f3ac2ed49d5 in __assert_fail () from /lib64/libc.so.6 #10 0x0000000001ee5214 in llvm::FoldingSetImpl::InsertNode(llvm::FoldingSetImpl::Node*, void*) () #11 0x0000000001ee54b2 in llvm::FoldingSetImpl::GetOrInsertNode(llvm::FoldingSetImpl::Node*) () #12 0x0000000001352691 in llvm::FoldingSet<clang::FunctionTemplateSpecializationInfo>::GetOrInsertNode(llvm::FoldingSetImpl::Node*) () #13 0x0000000001351c48 in llvm::FoldingSetVector<clang::FunctionTemplateSpecializationInfo, llvm::SmallVector<clang::FunctionTemplateSpecializationInfo*, 8u> >::GetOrInsertNode(clang::FunctionTemplateSpecializationInfo*) () #14 0x000000000134dce4 in clang::FunctionTemplateDecl::addSpecialization(clang::FunctionTemplateSpecializationInfo*, void*) () #15 0x00000000009a152a in cling::DeclReverter::VisitFunctionDecl(clang::FunctionDecl*)::FunctionTemplateDeclExt::removeSpecialization(clang::FunctionTemplateDecl*, clang::FunctionTemplateSpecializationInfo const*) () #16 0x00000000009a15fb in cling::DeclReverter::VisitFunctionDecl(clang::FunctionDecl*) () #17 0x00000000009a4b39 in clang::DeclVisitor<cling::DeclReverter, bool>::VisitCXXMethodDecl(clang::CXXMethodDecl*) () #18 0x00000000009a36a2 in clang::DeclVisitor<cling::DeclReverter, bool>::Visit(clang::Decl*) () #19 0x00000000009a2ae1 in cling::DeclReverter::RevertDecl(clang::Decl*) () #20 0x00000000009a1fcd in cling::ASTNodeEraser::RevertTransaction(cling::Transaction const*) () #21 0x000000000099845f in cling::IncrementalParser::rollbackTransaction(cling::Transaction*) const () #22 0x00000000009980ff in cling::IncrementalParser::commitCurrentTransaction() () #23 0x00000000009985e8 in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () #24 0x000000000097e3a4 in cling::Interpreter::EvaluateInternal(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions const&, cling::StoredValueRef*) () #25 0x000000000097d944 in cling::Interpreter::process(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::StoredValueRef*, clang::Decl const**) () #26 0x000000000097686b in cling::MetaProcessor::process(char const*, cling::StoredValueRef*, cling::Interpreter::CompilationResult*) () #27 0x0000000000962ea0 in cling::UserInterface::runInteractively(bool) () #28 0x00000000009625e7 in main ()

#4 <signal handler called> #5 0x00007f8e9198ba45 in raise () from /lib64/libc.so.6 #6 0x00007f8e9198d225 in abort () from /lib64/libc.so.6 #7 0x00007f8e919849d5 in __assert_fail () from /lib64/libc.so.6 #8 0x00000000009baba7 in llvm::isa_impl_cl<clang::TranslationUnitDecl, clang::Decl*>::doit(clang::Decl const*) () #9 0x00000000009b9e81 in llvm::isa_impl_wrap<clang::TranslationUnitDecl, clang::Decl*, clang::Decl*>::doit(clang::Decl* const&) () #10 0x00000000009b6b74 in bool llvm::isa<clang::TranslationUnitDecl, clang::Decl*>(clang::Decl* const&) () #11 0x0000000000b27021 in llvm::cast_retty<clang::TranslationUnitDecl, clang::Decl*>::ret_type llvm::dyn_cast<clang::TranslationUnitDecl, clang::Decl*>(clang::Decl* const&) () #12 0x000000000132f082 in clang::Decl::getTranslationUnitDecl() () #13 0x000000000133308c in clang::Decl::getTranslationUnitDecl() const () #14 0x000000000132f140 in clang::Decl::getASTContext() const () #15 0x00000000013506b3 in clang::FunctionTemplateSpecializationInfo::Profile(llvm::FoldingSetNodeID&) () #16 0x000000000135355a in llvm::DefaultFoldingSetTrait<clang::FunctionTemplateSpecializationInfo>::Profile(clang::FunctionTemplateSpecializationInfo&, llvm::FoldingSetNodeID&) () #17 0x0000000001353391 in llvm::FoldingSet<clang::FunctionTemplateSpecializationInfo>::GetNodeProfile(llvm::FoldingSetImpl::Node*, llvm::FoldingSetNodeID&) const () #18 0x0000000001ee5467 in llvm::FoldingSetImpl::GetOrInsertNode(llvm::FoldingSetImpl::Node*) () #19 0x0000000001352691 in llvm::FoldingSet<clang::FunctionTemplateSpecializationInfo>::GetOrInsertNode(llvm::FoldingSetImpl::Node*) () #20 0x0000000001351c48 in llvm::FoldingSetVector<clang::FunctionTemplateSpecializationInfo, llvm::SmallVector<clang::FunctionTemplateSpecializationInfo*, 8u> >::GetOrInsertNode(clang::FunctionTemplateSpecializationInfo*) () #21 0x000000000134dce4 in clang::FunctionTemplateDecl::addSpecialization(clang::FunctionTemplateSpecializationInfo*, void*) () #22 0x00000000009a152a in cling::DeclReverter::VisitFunctionDecl(clang::FunctionDecl*)::FunctionTemplateDeclExt::removeSpecialization(clang::FunctionTemplateDecl*, clang::FunctionTemplateSpecializationInfo const*) () #23 0x00000000009a15fb in cling::DeclReverter::VisitFunctionDecl(clang::FunctionDecl*) () #24 0x00000000009a4b39 in clang::DeclVisitor<cling::DeclReverter, bool>::VisitCXXMethodDecl(clang::CXXMethodDecl*) () #25 0x00000000009a4b5f in clang::DeclVisitor<cling::DeclReverter, bool>::VisitCXXConstructorDecl(clang::CXXConstructorDecl*) () #26 0x00000000009a36ba in clang::DeclVisitor<cling::DeclReverter, bool>::Visit(clang::Decl*) () #27 0x00000000009a2ae1 in cling::DeclReverter::RevertDecl(clang::Decl*) () #28 0x00000000009a1fcd in cling::ASTNodeEraser::RevertTransaction(cling::Transaction const*) () #29 0x000000000099845f in cling::IncrementalParser::rollbackTransaction(cling::Transaction*) const () #30 0x00000000009980ff in cling::IncrementalParser::commitCurrentTransaction() () #31 0x00000000009985e8 in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () #32 0x000000000097e20f in cling::Interpreter::DeclareInternal(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions const&, clang::Decl const**) () #33 0x000000000097daf4 in cling::Interpreter::declare(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::Decl const**) () #34 0x000000000097d924 in cling::Interpreter::process(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::StoredValueRef*, clang::Decl const**) () #35 0x000000000097686b in cling::MetaProcessor::process(char const*, cling::StoredValueRef*, cling::Interpreter::CompilationResult*) () #36 0x0000000000962ea0 in cling::UserInterface::runInteractively(bool) () #37 0x00000000009625e7 in main ()

And here is the stack when __dso_handle is not found (removing my hack and putting a break point at the error condition):

#0 0x0000000001532dea in llvm::JIT::getOrEmitGlobalVariable(llvm::GlobalVariable const*) () #1 0x000000000153afec in (anonymous namespace)::JITEmitter::getPointerToGlobal(llvm::GlobalValue*, void*, bool) () #2 0x000000000153b9c9 in (anonymous namespace)::JITEmitter::finishFunction(llvm::MachineFunction&) () #3 0x00000000015fe744 in (anonymous namespace)::Emitter<llvm::JITCodeEmitter>::runOnMachineFunction(llvm::MachineFunction&) () #4 0x0000000001a01959 in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) () #5 0x0000000001e29139 in llvm::FPPassManager::runOnFunction(llvm::Function&) () #6 0x0000000001e28e55 in llvm::FunctionPassManagerImpl::run(llvm::Function&) () #7 0x0000000001e28b05 in llvm::FunctionPassManager::run(llvm::Function&) () #8 0x000000000153275a in llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) () #9 0x00000000015326af in llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard const&) () #10 0x0000000001532a32 in llvm::JIT::getPointerToFunction(llvm::Function*) () #11 0x0000000001531302 in llvm::JIT::runFunction(llvm::Function*, std::vector<llvm::GenericValue, std::allocator<llvm::GenericValue> > const&) () #12 0x000000000155a770 in llvm::ExecutionEngine::runStaticConstructorsDestructors(llvm::Module*, bool) () #13 0x000000000155a811 in llvm::ExecutionEngine::runStaticConstructorsDestructors(bool) () #14 0x0000000000993d1e in cling::ExecutionContext::runStaticInitializersOnce(llvm::Module*) () #15 0x000000000097ead3 in cling::Interpreter::runStaticInitializersOnce() const () #16 0x00000000009983c4 in cling::IncrementalParser::commitCurrentTransaction() () #17 0x00000000009985e8 in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () #18 0x000000000097e20f in cling::Interpreter::DeclareInternal(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions const&, clang::Decl const**) () #19 0x000000000097daf4 in cling::Interpreter::declare(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::Decl const**) () #20 0x000000000097c710 in cling::Interpreter::Interpreter(int, char const* const*, char const*) () #21 0x0000000000962374 in main ()


Jeremy

Hi,
Now I understand. This issue is independent of the dso handle. Cling’s error recovery system is not able to revert all kinds of declarations at this moment. So this is expected for now. What kind of input causes the errors?
Cheers,
Vassil

Ah, OK. I’m loading many complex headers and libraries, but doing simple things with them (I’m just instantiating types from our existing libraries).

Unfortunately, I can’t disclose anything that’s going on in the headers publicly.

Any thoughts on how to fix the __dso_handle issue without the hack to LLVM?

Hi,
I understand but “just instantiating a template” is the most scary thing for cling (and C++ in general). That functionality is missing when it comes to templated classes and limited for for templated functions. We need it very much, too, but we have more important things to do.
Frankly speaking I think we will have it mid-next year. Here to say: patches into that direction are very welcome.
Maybe you should ask on LLVM’s mailing list why is that on RHEL. Maybe it’s just a bug.
Vassil

Ah, that’s unfortunate; since so much of our code is templated, it would mean frequent crashes and frustration.

If we decide to use cling on a larger scale, perhaps we will be able to help out, but right now it’s just a personal project that I’m exploring.

Do you have any docs/thoughts on how to improve the stability of template instantiation? Having a plan or something like that would definitely help motivate outside contributions (at least for me :slight_smile: ).


Jeremy

Hi,
The best way to go is to come up with tiny examples, which reproduce the problem/crash and submit a bug here: savannah.cern.ch/bugs/?func=add … up=savroot
I am not sure what exactly do you mean by plan. For sure we will fix the template instantiation error recovery issues - that is the plan. The rest of it is reproducers and bug reports. And this is the easiest way to for new contributors enter that world :slight_smile:
I’d be glad to see it in another large scale project. If you need further details please don’t hesitate to contact me in private.
Vassil

Ok, I’ll try to get a simple repro case and report a bug tomorrow.

I’ve been poking around the cling internals and have some questions, but I’ll contact you directly about that.

Thanks!


Jeremy