llvm / llvm-project

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

[Libvlc/thread_local]Error in WasmObjectWriter : Assertion `Sec.getKind().isMetadata()' failed. #41855

Open llvmbot opened 5 years ago

llvmbot commented 5 years ago
Bugzilla Link 42510
Version trunk
OS Linux
Attachments Run script, Preprocessed source with run script
Reporter LLVM Bugzilla Contributor
CC @aheejin,@dschuff,@tlively

Extended Description

Hi,

Enabling -pthread as a CFLAG in our build system causes a crash in clang-9. I will give the trace and source file with the run script. More details to come in the comments.

Trace: clang-9: /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp:1293: virtual uint64_t (anonymous namespace)::WasmObjectWriter::writeObject(llvm::MCAssembler &, const llvm::MCAsmLayout &): Assertion `Sec.getKind().isMetadata()' failed. Stack dump:

  1. Program arguments: /home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9 -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all -disable-free -main-file-name interrupt.c -mrelocation-model static -mthread-model posix -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fno-trapping-math -masm-verbose -mconstructor-aliases -fuse-init-array -target-feature +atomics -target-cpu generic -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /home/b1ue/vlc/vlc/build-em/src/misc/interrupt.gcno -nostdsysteminc -nobuiltininc -resource-dir /home/b1ue/b1ue/workdir_vlc/emsdk/upstream/lib/clang/9.0.0 -dependency-file misc/.deps/interrupt.Tpo -sys-header-deps -MP -MT misc/interrupt.lo -D EMSCRIPTEN_major=1 -D EMSCRIPTEN_minor=38 -D EMSCRIPTEN_tiny__=37 -D _LIBCPP_ABI_VERSION=2 -D unix -D unix -D unix -D HAVE_CONFIG_H -I . -I ../../src -I .. -D MODULE_STRING="core" -D SYSDATADIR="/usr/local/share" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D LOCALEDIR="/usr/local/share/locale" -D PKGDATADIR="/usr/local/share/vlc" -D PKGLIBDIR="/usr/local/lib/vlc" -D PKGLIBEXECDIR="/usr/local/libexec/vlc" -I ../../include -I ../include -I /home/b1ue/vlc/vlc/contrib/wasm32-unknown-emscripten/include -D NEED_ssize_t -I /home/b1ue/vlc/vlc/contrib/wasm32-unknown-emscripten/include -D EMSCRIPTEN_PTHREADS__=1 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=invalid-command-line-argument -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -fconst-strings -fdebug-compilation-dir /home/b1ue/vlc/vlc/build-em/src -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -funroll-loops -pthread -stack-protector 2 -fobjc-runtime=gnustep -fno-common -fdiagnostics-show-option -fcolor-diagnostics -nobuiltininc -nostdsysteminc -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/include/libcxx -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/lib/libcxxabi/include -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/include/compat -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/include -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/include/libc -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/local/include -isystem/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/emscripten/system/include/SDL -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o misc/interrupt.o -x c ../../src/misc/interrupt.c
  2. parser at end of file
  3. Code generation

    ​0 0x00007fddcea3d3e4 PrintStackTraceSignalHandler(void*) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0x6b13e4)

    ​1 0x00007fddcea3b0de llvm::sys::RunSignalHandlers() (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0x6af0de)

    ​2 0x00007fddcea3d698 SignalHandler(int) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0x6b1698)

    ​3 0x00007fddd17bbcb0 __restore_rt (/usr/lib/libpthread.so.0+0x13cb0)

    ​4 0x00007fddcdebb755 __GI_raise (/usr/lib/libc.so.6+0x3a755)

    ​5 0x00007fddcdea6851 __GI_abort (/usr/lib/libc.so.6+0x25851)

    ​6 0x00007fddcdea6727 _nl_load_domain.cold (/usr/lib/libc.so.6+0x25727)

    ​7 0x00007fddcdeb4026 (/usr/lib/libc.so.6+0x33026)

    ​8 0x00007fddcfce5c16 (anonymous namespace)::WasmObjectWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout const&) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0x1959c16)

    ​9 0x00007fddcfc94706 llvm::MCAssembler::Finish() (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0x1908706)

    ​10 0x00007fddcf20e45c llvm::AsmPrinter::doFinalization(llvm::Module&) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0xe8245c)

    ​11 0x00007fddceb88645 llvm::FPPassManager::doFinalization(llvm::Module&) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0x7fc645)

    ​12 0x00007fddceb88c96 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/../lib/libLLVM-9svn.so+0x7fcc96)

    ​13 0x0000000000652ddc 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 >) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0x652ddc)

    ​14 0x0000000000d6b025 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0xd6b025)

    ​15 0x00000000012fecf3 clang::ParseAST(clang::Sema&, bool, bool) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0x12fecf3)

    ​16 0x0000000000b642f0 clang::FrontendAction::Execute() (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0xb642f0)

    ​17 0x0000000000b094f1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0xb094f1)

    ​18 0x0000000000bff12d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0xbff12d)

    ​19 0x0000000000612034 cc1_main(llvm::ArrayRef<char const>, char const, void*) (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0x612034)

    ​20 0x0000000000610084 main (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0x610084)

    ​21 0x00007fddcdea7ee3 __libc_start_main (/usr/lib/libc.so.6+0x26ee3)

    ​22 0x000000000060d329 _start (/home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin/clang-9+0x60d329)

    clang-9: error: unable to execute command: Aborted (core dumped) clang-9: error: clang frontend command failed due to signal (use -v to see invocation) clang version 9.0.0 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project 922759a63d7d8edbc47578b4718a38765093d24e) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /home/b1ue/b1ue/workdir_vlc/emsdk/upstream/bin clang-9: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. clang-9: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-9: note: diagnostic msg: /tmp/interrupt-32bf76.c clang-9: note: diagnostic msg: /tmp/interrupt-32bf76.sh clang-9: note: diagnostic msg:


dschuff commented 5 years ago

thread_local isn't supported yet in wasm. It's something we'd like to fix in the near future. It also requires support from the C library. We'd implement it in emscripten. In the future, if and when WASI gets threading support it would make sense to implement it there too, and make the interface the same.

llvmbot commented 5 years ago

Simple example to be able to reproduce the bug

llvmbot commented 5 years ago

I can reproduce the bug on a much simpler example:

include

include

thread_local int a;

int main() { printf("%d\n", a);

}

(Previous message was interrupted, I'll continue here)

For the first example I gave, if we comment out the calls to vlc_interrupt_var, which is a thread_local variable, the file compiles.

For the simple (and short) main.c example. If we compile using -pthread, the compiler will crash. See main.zip attachement for the Preprocessed source and associated run script.

clang-9 --target=wasm32-unknown-emscripten -I ../../emsdk/upstream/emscripten/system/include/ -pthread main.c

I hope this helps. Do not hesitate to reach out for further discussion.

Regards,

llvmbot commented 5 years ago

I can reproduce the bug on a much simpler example:

include

include

thread_local int a;

int main() { printf("%d\n", a);

}