llvm / llvm-project

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

wasm-ld crashes with --compress-relocations #110045

Open TerrorJack opened 3 weeks ago

TerrorJack commented 3 weeks ago

Repro: get release-artifacts from CI output of latest revision in https://github.com/WebAssembly/wasi-sdk, which uses llvm 19.1.0. Then compile the following program:

#include <iostream>

int main(void) {
  std::cout << "yolo" << std::endl;
  return 0;
}

With something like: /tmp/wasi-sdk/bin/wasm32-wasi-clang++ test.cpp -o test.wasm -Wl,--compress-relocations,--strip-all

It will crash with the following error message:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x00007f312b0c0091 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/tmp/wasi-sdk/bin/../lib/libLLVM.so.19.1-wasi-sdk+0x8c0091)
 #1 0x00007f312b0be5e5 llvm::sys::RunSignalHandlers() (/tmp/wasi-sdk/bin/../lib/libLLVM.so.19.1-wasi-sdk+0x8be5e5)
 #2 0x00007f312b0bf4f4 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f312a605320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
 #4 0x000055d3454f97f9 lld::wasm::InputFunction::writeCompressed(unsigned char*) const (/tmp/wasi-sdk/bin/wasm-ld+0x2f97f9)
 #5 0x000055d34551b6a6 lld::wasm::CodeSection::writeTo(unsigned char*) (/tmp/wasi-sdk/bin/wasm-ld+0x31b6a6)
 #6 0x00007f312b06ae47 std::_Function_handler<void (), llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::'lambda'()>::_M_invoke(std::_Any_data const&) Parallel.cpp:0:0
 #7 0x00007f312b06add7 std::_Function_handler<void (), llvm::parallel::TaskGroup::spawn(std::function<void ()>, bool)::'lambda'()>::_M_invoke(std::_Any_data const&) Parallel.cpp:0:0
 #8 0x00007f312b06b365 llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) Parallel.cpp:0:0
 #9 0x00007f312c6a420f execute_native_thread_routine thread.o:0:0
#10 0x00007f312a65ca94 start_thread ./nptl/pthread_create.c:447:8
#11 0x00007f312a6e9c3c clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80:0
wasm32-wasi-clang++: error: unable to execute command: Segmentation fault
wasm32-wasi-clang++: error: linker command failed due to signal (use -v to see invocation)
llvmbot commented 3 weeks ago

@llvm/issue-subscribers-lld-wasm

Author: Cheng Shao (TerrorJack)

Repro: get `release-artifacts` from CI output of latest revision in https://github.com/WebAssembly/wasi-sdk, which uses llvm 19.1.0. Then compile the following program: ```c++ #include <iostream> int main(void) { std::cout << "yolo" << std::endl; return 0; } ``` With something like: `/tmp/wasi-sdk/bin/wasm32-wasi-clang++ test.cpp -o test.wasm -Wl,--compress-relocations,--strip-all` It will crash with the following error message: ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. #0 0x00007f312b0c0091 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/tmp/wasi-sdk/bin/../lib/libLLVM.so.19.1-wasi-sdk+0x8c0091) #1 0x00007f312b0be5e5 llvm::sys::RunSignalHandlers() (/tmp/wasi-sdk/bin/../lib/libLLVM.so.19.1-wasi-sdk+0x8be5e5) #2 0x00007f312b0bf4f4 SignalHandler(int) Signals.cpp:0:0 #3 0x00007f312a605320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320) #4 0x000055d3454f97f9 lld::wasm::InputFunction::writeCompressed(unsigned char*) const (/tmp/wasi-sdk/bin/wasm-ld+0x2f97f9) #5 0x000055d34551b6a6 lld::wasm::CodeSection::writeTo(unsigned char*) (/tmp/wasi-sdk/bin/wasm-ld+0x31b6a6) #6 0x00007f312b06ae47 std::_Function_handler<void (), llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::'lambda'()>::_M_invoke(std::_Any_data const&) Parallel.cpp:0:0 #7 0x00007f312b06add7 std::_Function_handler<void (), llvm::parallel::TaskGroup::spawn(std::function<void ()>, bool)::'lambda'()>::_M_invoke(std::_Any_data const&) Parallel.cpp:0:0 #8 0x00007f312b06b365 llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) Parallel.cpp:0:0 #9 0x00007f312c6a420f execute_native_thread_routine thread.o:0:0 #10 0x00007f312a65ca94 start_thread ./nptl/pthread_create.c:447:8 #11 0x00007f312a6e9c3c clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:80:0 wasm32-wasi-clang++: error: unable to execute command: Segmentation fault wasm32-wasi-clang++: error: linker command failed due to signal (use -v to see invocation) ```