| Issue |
178135
|
| Summary |
[lld][WebAssembly] wasm-ld ICE in WebAssembly Instruction Selection
|
| Labels |
lld
|
| Assignees |
|
| Reporter |
gl84
|
While trying to build a shared png library with emscripten I encountered a crash in wasm-ld (emscripten-core/emscripten#26165).
Steps to reproduce the crash with llvm only:
Create a file pngerror.c
```c
#include "setjmp.h"
extern void call_free(void* ptr);
void png_free_jmpbuf(jmp_buf *jb) {
call_free(jb);
jmp_buf free_jmp_buf;
setjmp(free_jmp_buf);
}
```
Compile and link pngerror.c with:
```sh
/home/playground/emsdk_5.0.0/emsdk/upstream/bin/clang-23 -cc1 -triple wasm32 -O0 -emit-llvm-bc -main-file-name pngerror.c -internal-isystem /home/playground/emsdk_5.0.0/emsdk/upstream/emscripten/cache/sysroot/include -fignore-exceptions -o pngerror.c.o -x c pngerror.c && /home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld -o libpng.so -shared pngerror.c.o -mllvm -wasm-enable-sjlj -mllvm -exception-model=wasm
```
This results in the following ICE:
```
LLVM ERROR: Cannot select: 0x5ace594345d0: ch = catchret 0x5ace593f9cc8, BasicBlock:ch< 0x5ace5942d708>, BasicBlock:ch< 0x5ace5942d5a8>
In function: png_free_jmpbuf
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld -o libpng.so -shared pngerror.c.o -mllvm -wasm-enable-sjlj -mllvm -exception-model=wasm
1. Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2. Running pass 'WebAssembly Instruction Selection' on function '@png_free_jmpbuf'
#0 0x00005ace1792e0e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x11560e8)
#1 0x00005ace1792ae25 llvm::sys::RunSignalHandlers() (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x1152e25)
#2 0x00005ace1792ec96 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007b7158645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x00007b715869eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007b715869eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007b715869eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007b715864527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007b71586288ff abort ./stdlib/abort.c:81:7
#9 0x00005ace1788b216 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x10b3216)
#10 0x00005ace188714dc llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x20994dc)
#11 0x00005ace18870a55 (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x2098a55)
#12 0x00005ace17f33f7e (anonymous namespace)::WebAssemblyDAGToDAGISel::Select(llvm::SDNode*) (.llvm.406094044484436182) WebAssemblyISelDAGToDAG.cpp:0:0
#13 0x00005ace18866e5c llvm::SelectionDAGISel::DoInstructionSelection() (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x208ee5c)
#14 0x00005ace18866330 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x208e330)
#15 0x00005ace188658ad llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x208d8ad)
#16 0x00005ace188621e7 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x208a1e7)
#17 0x00005ace1885f4a4 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x20874a4)
#18 0x00005ace18bc7723 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x23ef723)
#19 0x00005ace1a7e2393 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x400a393)
#20 0x00005ace1a7ea56c llvm::FPPassManager::runOnModule(llvm::Module&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x401256c)
#21 0x00005ace1a7e3244 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x400b244)
#22 0x00005ace184522f9 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::__2::function<llvm::Expected<std::__2::unique_ptr<llvm::CachedFileStream, std::__2::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) LTOBackend.cpp:0:0
#23 0x00005ace18450c3d llvm::lto::backend(llvm::lto::Config const&, std::__2::function<llvm::Expected<std::__2::unique_ptr<llvm::CachedFileStream, std::__2::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x1c78c3d)
#24 0x00005ace18432e0e llvm::lto::LTO::runRegularLTO(std::__2::function<llvm::Expected<std::__2::unique_ptr<llvm::CachedFileStream, std::__2::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x1c5ae0e)
#25 0x00005ace18431ea7 llvm::lto::LTO::run(std::__2::function<llvm::Expected<std::__2::unique_ptr<llvm::CachedFileStream, std::__2::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::FileCache) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x1c59ea7)
#26 0x00005ace17e49e58 lld::wasm::BitcodeCompiler::compile() (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x1671e58)
#27 0x00005ace17e4dd34 lld::wasm::SymbolTable::compileBitcodeFiles() (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x1675d34)
#28 0x00005ace17e33601 lld::wasm::(anonymous namespace)::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) Driver.cpp:0:0
#29 0x00005ace17e2de7a lld::wasm::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x1655e7a)
#30 0x00005ace17932c2c lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x115ac2c)
#31 0x00005ace178677f1 lld_main(int, char**, llvm::ToolContext const&) (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x108f7f1)
#32 0x00005ace17867f14 main (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0x108ff14)
#33 0x00007b715862a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#34 0x00007b715862a28b call_init ./csu/../csu/libc-start.c:128:20
#35 0x00007b715862a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#36 0x00005ace177ce22a _start (/home/playground/emsdk_5.0.0/emsdk/upstream/bin/wasm-ld+0xff622a)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs