wasm backend segfault with -fcommon
| Bugzilla Link | 34075 |
| Resolution | WONTFIX |
| Resolved on | May 24, 2019 16:00 |
| Version | trunk |
| OS | Linux |
| Attachments | C source generated with error, sh file generated with error |
| CC | @dschuff,@sunfishcode,@Madgen-content,@sbc100 |
Extended Description
#0 0x0000000001e33d6a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin/clang-6.0+0x1e33d6a) #1 0x0000000001e31f1e llvm::sys::RunSignalHandlers() (/nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin/clang-6.0+0x1e31f1e) #2 0x0000000001e3206c SignalHandler(int) (/nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin/clang-6.0+0x1e3206c) #3 0x00007f4a6e43b840 __restore_rt (/nix/store/f111ij1fc83965m48bf2zqgiaq88fqv5-glibc-2.25/lib/libpthread.so.0+0x11840) #4 0x0000000001b87ec4 llvm::MCAssembler::registerSymbol(llvm::MCSymbol const&, bool*) (/nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin/clang-6.0+0x1b87ec4) #5 0x0000000001bb84ee llvm::MCWasmStreamer::EmitWeakReference(llvm::MCSymbol*, llvm::MCSymbol const*) (/nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin/clang-6.0+0x1bb84ee) #6 0x00000000040d5c7b _fini (/nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin/clang-6.0+0x40d5c7b) Stack dump: 0. Program arguments: /nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin/clang-6.0 -cc1 -triple wasm32-unknown-unknown-wasm -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name tmp.c -mrelocation-model static -mthread-model posix -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -fvisibility hidden -momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -coverage-notes-file /home/nox/Documents/ghc/includes/dist-derivedconstants/header/tmp.gcno -nostdsysteminc -nobuiltininc -resource-dir /nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/lib/clang/6.0.0 -idirafter /nix/store/djszqfrlmxj8gbp0q3p9s9ihbdz0q3gw-musl-wasm32-unknown-unknown-wasm/include -idirafter /nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/lib/gcc///include-fixed -isystem /nix/store/ilaj538k2z7bqvwby699z2r2hwjajmzv-llvm/include -isystem /nix/store/c24pf8amzw30zs34l13agxdqqv2hfjv5-ncurses-6.0-dev/include -isystem /nix/store/aph8ialplvlnijrk1gmz18fxwbljz4lp-ncurses-6.0-wasm32-unknown-unknown-wasm-dev/include -D USE_MINIINTERPRETER -I includes -I includes/dist -I includes/dist-derivedconstants/header -I includes/dist-ghcconstants/header -I rts -D NOSMP -D _FORTIFY_SOURCE=2 -O2 -Wall -Wno-unknown-pragmas -Wformat -Wformat-security -Werror=format-security -fdebug-compilation-dir /home/nox/Documents/ghc -ferror-limit 19 -fmessage-length 271 -fwrapv -stack-protector 2 -stack-protector-buffer-size 4 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o includes/dist-derivedconstants/header/tmp.o -x c includes/dist-derivedconstants/header/tmp.c
-
<eof> parser at end of file -
Code generation
clang-6.0: error: unable to execute command: Segmentation fault clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation) clang version 6.0.0 Target: wasm32-unknown-unknown-wasm Thread model: posix InstalledDir: /nix/store/bbkn1122s3ndcf9z30zf286jvm27qrxi-clang/bin clang-6.0: note: diagnostic msg: PLEASE submit a bug report to and include the crash backtrace, preprocessed source, and associated run script. clang-6.0: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-6.0: note: diagnostic msg: /run/user/1000/tmp-9f0455.c clang-6.0: note: diagnostic msg: /run/user/1000/tmp-9f0455.sh clang-6.0: note: diagnostic msg:
Executing "/nix/store/dw234j7rigkn038r67lx0nbgbb56x60d-wasm32-unknown-unknown-wasm-clang-cross-wrapper/bin/wasm32-unknown-unknown-wasm-cc" failed compiler/ghc.mk:592: compiler/stage1/build/.depend-v.haskell: No such file or directory make[1]: *** [includes/ghc.mk:193: includes/dist-derivedconstants/header/DerivedConstants.h] Error 1 make: *** [Makefile:125: all] Error 2
We have no plans to support common symbols. It would be nice to give a nicer error when the flag is enabled, or somehow completely disable the flag.
I don't think we will implement "common" symbols on Wasm.
There's no clear use-case for it, it's a legacy C feature.
In your case, the .sh file indicates that your build system has explicitly passed "-fcommon", whereas by default Wasm uses "-fno-common", which avoids the problem.
I suppose we could make the error message nicer in case someone requests "-fcommon" for Wasm.
How far down on the priority list do common symbols sit? but yes I'd agree that throwing a real error would be an improvement in the meantime. Getting a segfault was a bit bewildering/troubling.
Ah, thanks for checking that out. I think we haven't implemented common symbols yet because we turn them off in Emscripten. But yeah, I imagine we would implement that along with support in lld (which is really where the interesting bits happen anyway). In the meantime maybe we should throw a real fatal error rather than an llvm_unreachable to make this easier to diagnose?
compiling the trouble file with a debug build. It complained about common symbols not yet being implemented for wasm. Sure enough, adding -fno-common allows the file to build just fine.
The debug trace is attached below.
Should this ticket be closed in favor of a implement common symbols ticket?
(apologies for the split message, saving other ticket changes sent it early)
Common symbols are not yet implemented for Wasm
UNREACHABLE executed at /home/nox/Documents/llvmbuild/llvm/lib/MC/MCWasmStreamer.cpp:133!
#0 0x00000000020ad6aa llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/nox/Documents/llvmbuild/llvm/lib/Support/Unix/Signals.inc:402:0
#1 0x00000000020ab61e llvm::sys::RunSignalHandlers() /home/nox/Documents/llvmbuild/llvm/lib/Support/Signals.cpp:50:0
#2 0x00000000020ab792 SignalHandler(int) /home/nox/Documents/llvmbuild/llvm/lib/Support/Unix/Signals.inc:242:0
#3 0x00007f2763155840 __restore_rt (/nix/store/kjwbqnh13dxh6w4pk2gb3ddmhpiaihqg-glibc-2.25/lib/libpthread.so.0+0x11840)
#4 0x00007f2761ca9384 __GI_raise (/nix/store/kjwbqnh13dxh6w4pk2gb3ddmhpiaihqg-glibc-2.25/lib/libc.so.6+0x33384)
#5 0x00007f2761caa7ea __GI_abort (/nix/store/kjwbqnh13dxh6w4pk2gb3ddmhpiaihqg-glibc-2.25/lib/libc.so.6+0x347ea)
#6 0x000000000205db8a /home/nox/Documents/llvmbuild/llvm/lib/Support/ErrorHandling.cpp:189:0
#7 0x0000000001e1b37c /home/nox/Documents/llvmbuild/llvm/lib/MC/MCWasmStreamer.cpp:133:0
#8 0x00000000026b3f64 llvm::AsmPrinter::EmitGlobalVariable(llvm::GlobalVariable const*) /home/nox/Documents/llvmbuild/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:501:0
#9 0x00000000026b49bd llvm::AsmPrinter::doFinalization(llvm::Module&) /home/nox/Documents/llvmbuild/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1274:0
#10 0x0000000001c0eb9f llvm::FPPassManager::doFinalization(llvm::Module&) /home/nox/Documents/llvmbuild/llvm/lib/IR/LegacyPassManager.cpp:1553:0
#11 0x0000000001c15b33 runOnModule /home/nox/Documents/llvmbuild/llvm/lib/IR/LegacyPassManager.cpp:1609:0
#12 0x0000000001c15b33 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/nox/Documents/llvmbuild/llvm/lib/IR/LegacyPassManager.cpp:1694:0
#13 0x0000000002242057 llvm::PrettyStackTraceString::~PrettyStackTraceString() /home/nox/Documents/llvmbuild/llvm/include/llvm/Support/PrettyStackTrace.h:52:0
#14 0x0000000002242057 EmitAssembly /home/nox/Documents/llvmbuild/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:792:0
#15 0x0000000002242057 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_deletellvm::raw_pwrite_stream >) /home/nox/Documents/llvmbuild/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1144:0
#16 0x0000000002928fb9 std::unique_ptr<llvm::raw_pwrite_stream, std::default_deletellvm::raw_pwrite_stream >::~unique_ptr() /nix/store/2m6v6lnmnf9521ixd5v0x4qrmjkn30ws-gcc-5.4.0/include/c++/5.4.0/bits/unique_ptr.h:235:0
#17 0x0000000002928fb9 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/nox/Documents/llvmbuild/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:261:0
#18 0x0000000002cd6fa8 void std::swap
-
<eof> parser at end of file -
Code generation
Aborted
Thanks for reporting this!
Sam/jacob, looks like a crash in MCWasmStreamer we should take a look at sometime.
Glad to help. I did finally get around to
Thanks for reporting this!
Sam/jacob, looks like a crash in MCWasmStreamer we should take a look at sometime.
building a valid C file results in clang segfaulting with the wasm backend. If I change the target triple to x86_64-unknown-linux-gnu the build command runs fine (although I have to remove the -target-cpu generic for that to work). To be clear, removing the target-cpu flag for the wasm target results in the same error.
The files mentioned by the error message are attached.
Are these files analagous to those produce by using -save-temps and reduction with delta as specified by https://llvm.org/docs/HowToSubmitABug.html ?
I can do that if necessary.
assigned to @sbc100