Help with segfault in llvm_shutdown with LLVM 5.0 Release build


We are upgrading an LLVM 4.0-based opt module to LLVM 5.0. After the upgrade our module works when built with an LLVM Debug build, but
with an LLVM Release build we are encountering the following error.

This happens after our passes have successfully run. I believe this has to do with the way our passes are registered. Would greatly appreciate some pointers, as to where to look.

Program received signal SIGSEGV, Segmentation fault.
#0 0x00007ffff6926c20 in ?? ()
#1 0x00005555561c333b in llvm::object_deleter<llvm::SmallVector<std::pair<llvm::PassManagerBuilder::ExtensionPointTy, std::function<void (llvm::PassManagerBuilder const&, llvm::legacy::PassManagerBase&)> >, 8u> >::call(void*) ()
#2 0x000055555658492d in llvm::ManagedStaticBase::destroy() const ()
#3 0x00005555565849e5 in llvm::llvm_shutdown() ()
#4 0x000055555589e0a2 in main ()


Does building with ASan help you localize the failure any better?

See for context. I thought we fixed the problem, but it looks like you found some other way to trigger it.


Thanks for the reference.

I realized after sending the last email that I missed two details. First, our module is an out-of-tree pass. Second, we are using add_library(Canary MODULE Canary.cpp).

Using the CMakeLists.txt from the patch you referred to as a reference I tried couple of changes in our CMakeLists.txt.

A) Changed the add_library command to SHARED_LIB
B) Added target_link_libraries(CanaryPass LLVMipo)

Now I am getting the following error:

opt: CommandLine Error: Option 'enable-partial-inlining' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options