https://bugs.llvm.org/show_bug.cgi?id=36807

            Bug ID: 36807
           Summary: Crash in WasmObjectWriter.cpp with `__thread`
                    variables
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: WebAssembly
          Assignee: unassignedb...@nondot.org
          Reporter: s...@chromium.org
                CC: llvm-bugs@lists.llvm.org

When compiling the following program:
```
__thread int a = 1;

int foo() {
  a = 2;
  return a;
}
```

Crash:

```
clang-7.0:
/usr/local/google/home/sbc/dev/wasm/llvm/lib/MC/WasmObjectWriter.cpp:1140:
virtual void (anonymous
namespace)::WasmObjectWriter::writeObject(llvm::MCAssembler &, const
llvm::MCAsmLayout &): Assertion `DataSection.isWasmData()' failed.
#0 0x00007f3a1e9119c4 PrintStackTraceSignalHandler(void*)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.7+0x1069c4)
#1 0x00007f3a1e911d26 SignalHandler(int)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.7+0x106d26)
#2 0x00007f3a1e2e80c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
#3 0x00007f3a1cb87fcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
#4 0x00007f3a1cb893fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
#5 0x00007f3a1cb80e37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
#6 0x00007f3a1cb80ee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
#7 0x00007f3a1ee2a085 (anonymous
namespace)::WasmObjectWriter::writeObject(llvm::MCAssembler&, llvm::MCAsmLayout
const&)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMMC.so.7+0x89085)
#8 0x00007f3a1ede1394 llvm::MCAssembler::Finish()
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMMC.so.7+0x40394)
#9 0x00007f3a1ca987ad llvm::AsmPrinter::doFinalization(llvm::Module&)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/libLLVMAsmPrinter.so.7+0x2f7ad)
#10 0x00007f3a1f393eff llvm::FPPassManager::doFinalization(llvm::Module&)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMCore.so.7+0x1b0eff)
#11 0x00007f3a1f3943a0 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMCore.so.7+0x1b13a0)
#12 0x00007f3a1db4dc8f 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/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangCodeGen.so.7+0x8fc8f)
#13 0x00007f3a1dd98fa2
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangCodeGen.so.7+0x2dafa2)
#14 0x00007f3a1b321f14 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/libclangParse.so.7+0x2df14)
#15 0x00007f3a1d87ac90 clang::FrontendAction::Execute()
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangFrontend.so.7+0xe5c90)
#16 0x00007f3a1d820791
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangFrontend.so.7+0x8b791)
#17 0x00007f3a2092bf46
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangFrontendTool.so.7+0x3f46)
#18 0x0000000000410006 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang-7.0+0x410006)
#19 0x000000000040e138 main
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang-7.0+0x40e138)
#20 0x00007f3a1cb752b1 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b1)
#21 0x000000000040b33a _start
(/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang-7.0+0x40b33a)
Stack dump:
0.      Program arguments:
/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang-7.0 -cc1 -triple
wasm32 -emit-obj -mrelax-all -disable-free -main-file-name test.c
-mrelocation-model static -mthread-model single -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu generic -fvisibility hidden
-dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer
-coverage-notes-file /usr/local/google/home/sbc/dev/wasm/llvm/test.gcno
-resource-dir /usr/local/google/home/sbc/dev/wasm/llvm-build/lib/clang/7.0.0
-internal-isystem /include -fdebug-compilation-dir
/usr/local/google/home/sbc/dev/wasm/llvm -ferror-limit 19 -fmessage-length 98
-fobjc-runtime=gnustep -fno-common -fdiagnostics-show-option
-fcolor-diagnostics -o test.o -x c test.c 
1.      <eof> parser at end of file
2.      Code generation
clang-7.0: error: unable to execute command: Aborted
clang-7.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.0 (trunk 327892) (llvm/trunk 327914)
Target: wasm32
Thread model: single
InstalledDir: /usr/local/google/home/sbc/dev/wasm/llvm/../llvm-build/bin
clang-7.0: 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-7.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-7.0: note: diagnostic msg: /tmp/test-f15c15.c
clang-7.0: note: diagnostic msg: /tmp/test-f15c15.sh
clang-7.0: note: diagnostic msg: 

********************
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to