llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.92k stars 11.53k forks source link

LLVM opt segfaults parsing arguments #65511

Open mauro-balades opened 1 year ago

mauro-balades commented 1 year ago
$ opt-15 -load /home/mauro/Downloads/alive2/build/tv/tv.so -load-pass-plugin=/home/mauro/Downloads/alive2/build/tv/tv.so -p tv -instcombine -o /dev/null foo.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: opt-15 -load /home/mauro/Downloads/alive2/build/tv/tv.so -load-pass-plugin=/home/mauro/Downloads/alive2/build/tv/tv.so -p tv -instcombine -o /dev/null foo.ll
 #0 0x00007f6cdf3043b1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf043b1)
 #1 0x00007f6cdf3020fe llvm::sys::RunSignalHandlers() (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf020fe)
 #2 0x00007f6cdf3048d6 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf048d6)
 #3 0x00007f6cddc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f6cdf2985f7 llvm::StringMapImpl::LookupBucketFor(llvm::StringRef) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe985f7)
 #5 0x00007f6cdf22092c (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe2092c)
 #6 0x00007f6cdf220b6e (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe20b6e)
 #7 0x00007f6cdf213e19 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe13e19)
 #8 0x00007f6cdf2127bb llvm::cl::Option::addArgument() (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe127bb)
 #9 0x00007f6cdba9562f llvm::cl::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>::list<char [8], llvm::cl::desc, llvm::cl::NumOccurrencesFlag, llvm::cl::value_desc, llvm::cl::cat>(char const (&) [8], llvm::cl::desc const&, llvm::cl::NumOccurrencesFlag const&, llvm::cl::value_desc const&, llvm::cl::cat const&) (/home/mauro/Downloads/alive2/build/tv/tv.so+0x8462f)
#10 0x00007f6cdba84dff __static_initialization_and_destruction_0(int, int) (.constprop.0) tv.cpp:0:0
#11 0x00007f6ce549847e call_init ./elf/dl-init.c:69:21
#12 0x00007f6ce5498568 _dl_init ./elf/dl-init.c:116:14
#13 0x00007f6cddd74c85 _dl_catch_exception ./elf/dl-error-skeleton.c:184:18
#14 0x00007f6ce549fff6 dl_open_worker ./elf/dl-open.c:812:6
#15 0x00007f6ce549fff6 dl_open_worker ./elf/dl-open.c:771:1
#16 0x00007f6cddd74c28 _dl_catch_exception ./elf/dl-error-skeleton.c:209:18
#17 0x00007f6ce54a034e _dl_open ./elf/dl-open.c:883:17
#18 0x00007f6cddc906bc dlopen_doit ./dlfcn/dlopen.c:56:13
#19 0x00007f6cddd74c28 _dl_catch_exception ./elf/dl-error-skeleton.c:209:18
#20 0x00007f6cddd74cf3 _dl_catch_error ./elf/dl-error-skeleton.c:228:12
#21 0x00007f6cddc901ae _dlerror_run ./dlfcn/dlerror.c:145:17
#22 0x00007f6cddc90748 dlopen_implementation ./dlfcn/dlopen.c:71:51
#23 0x00007f6cddc90748 dlopen ./dlfcn/dlopen.c:81:12
#24 0x00007f6cdf2ee439 llvm::sys::DynamicLibrary::getPermanentLibrary(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xeee439)
#25 0x00007f6cdf276cc1 llvm::PluginLoader::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe76cc1)
#26 0x0000558b8a0150a5 (/usr/lib/llvm-15/bin/opt+0x360a5)
#27 0x00007f6cdf2150a6 (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe150a6)
#28 0x00007f6cdf2187bb llvm::cl::ParseCommandLineOptions(int, char const* const*, llvm::StringRef, llvm::raw_ostream*, char const*, bool) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xe187bb)
#29 0x0000558b8a0113a9 main (/usr/lib/llvm-15/bin/opt+0x323a9)
#30 0x00007f6cddc29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007f6cddc29e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007f6cddc29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x0000558b89ffa905 _start (/usr/lib/llvm-15/bin/opt+0x1b905)
Segmentation fault
EugeneZelenko commented 1 year ago

Could you please try 17 Release Candidate or main branch?

aeubanks commented 1 year ago

you might have multiple copies of LLVM throughout the various libraries and the main binary loaded? that'll cause initialization issues