clang segfaults when compiling LLVM IR

安稳与你 提交于 2019-12-14 03:08:45

问题


I am trying to compile a LLVM IR file. However, when I try to compile it, I get this stack trace:

warning: overriding the module target triple with x86_64-pc-linux-gnu [-Woverride-module]
#0 0x00007f415c9179fa llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x8549fa)
#1 0x00007f415c915c76 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x852c76)
#2 0x00007f415c915dab (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x852dab)
#3 0x00007f415fc65890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
#4 0x00007f415cf80c0a llvm::DwarfDebug::collectVariableInfo(llvm::DwarfCompileUnit&, llvm::DISubprogram const*, llvm::DenseSet<std::pair<llvm::DILocalVariable const*, llvm::DILocation const*>, llvm::DenseMapInfo<std::pair<llvm::DILocalVariable const*, llvm::DILocation const*> > >&) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0xebdc0a)
#5 0x00007f415cf826b9 llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0xebf6b9)
#6 0x00007f415cf5a6d4 llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0xe976d4)
#7 0x00007f415cf4b587 llvm::AsmPrinter::EmitFunctionBody() (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0xe88587)
#8 0x00007f415e40155b (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x233e55b)
#9 0x00007f415cbbd740 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0xafa740)
#10 0x00007f415c9f2d18 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x92fd18)
#11 0x00007f415c9f2d63 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x92fd63)
#12 0x00007f415c9f25af llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x92f5af)
#13 0x000055b5a2be15b2 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/usr/lib/llvm-6.0/bin/clang+0x4af5b2)
#14 0x000055b5a318c1f7 clang::CodeGenAction::ExecuteAction() (/usr/lib/llvm-6.0/bin/clang+0xa5a1f7)
#15 0x000055b5a2fc2e16 clang::FrontendAction::Execute() (/usr/lib/llvm-6.0/bin/clang+0x890e16)
#16 0x000055b5a2f8cebc clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-6.0/bin/clang+0x85aebc)
#17 0x000055b5a306e213 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-6.0/bin/clang+0x93c213)
#18 0x000055b5a2b8b938 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-6.0/bin/clang+0x459938)
#19 0x000055b5a2b7a302 main (/usr/lib/llvm-6.0/bin/clang+0x448302)
#20 0x00007f415b16cb97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#21 0x000055b5a2b8939a _start (/usr/lib/llvm-6.0/bin/clang+0x45739a)
Stack dump:
0.  Program arguments: /usr/lib/llvm-6.0/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name blackjack.xan.ll -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=gdb -resource-dir /usr/lib/llvm-6.0/lib/clang/6.0.1 -O0 -fdebug-compilation-dir /home/proc-daemon/Dropbox/Xanathar/xanathar -ferror-limit 19 -fmessage-length 0 -fsanitize=address -fsanitize-blacklist=/usr/lib/llvm-6.0/lib/clang/6.0.1/asan_blacklist.txt -fsanitize-address-use-after-scope -fno-assume-sane-operator-new -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/blackjack-20cd92.o -x ir tests/blackjack/blackjack.xan.ll
1.  Code generation
2.  Running pass 'Function Pass Manager' on module 'tests/blackjack/blackjack.xan.ll'.
3.  Running pass 'X86 Assembly Printer' on function '@num_to_char'
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.1-svn334776-1~exp1~20181018152737.116 (branches/release_60)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: Error generating preprocessed source(s).

Here is the IR that causes the segfault (>30k char). The clang invocation: clang -g -fstandalone-debug -fsanitize=address -O0 tests/blackjack/blackjack.xan.ll /home/proc-daemon/Dropbox/Xanathar/xanathar/stdlib/stdio.so /home/proc-daemon/Dropbox/Xanathar/xanathar/stdlib/stdlib.so /home/proc-daemon/Dropbox/Xanathar/xanathar/stdlib/random.so -o tests/blackjack/blackjack.xan.o.

Updating clang to 7.0 and llvmlite to 0.27.0 did not change anything, except for the paths in the clang stacktrace.

来源:https://stackoverflow.com/questions/54081557/clang-segfaults-when-compiling-llvm-ir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!