Open
Description
Hi,
I got a crash while using wasm-ld. Here's the full command and output:
$ dune exec -- owi c -O3 -vv --testcomp bench/testcomp/sv-benchmarks/c/hardware-verification-bv/btor2c-lazyMod.shift_register_top_w128_d8_e0.c
owi: [EXEC:216699] ['/usr/bin/clang' '-O3' '--target=wasm32' '-m32'
'-ffreestanding' '--no-standard-libraries'
'-Wno-everything' '-flto=thin' '-Wl,--entry=main'
'-Wl,--export=main' '-Wl,--lto-O0'
'-Wl,-z,stack-size=8388608' '-I'
'/home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files'
'-o' '/tmp/owi_c_ebc58a/a.out.wasm'
'/home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libc.wasm'
'/home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libowi.wasm'
'bench/testcomp/sv-benchmarks/c/hardware-verification-bv/btor2c-lazyMod.shift_register_top_w128_d8_e0.c']
wasm-ld-19: warning: function signature mismatch: free
>>> defined as (i32) -> i32 in /home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libowi.wasm
>>> defined as (i32) -> void in /home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libc.wasm
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /usr/bin/wasm-ld-19 -m wasm32 -L/usr/lib --entry=main --export=main --lto-O0 -z stack-size=8388608 /home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libc.wasm /home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libowi.wasm /tmp/btor2c-lazyMod-fa4c77.o -o /tmp/owi_c_ebc58a/a.out.wasm --keep-section=target_features
#0 0x00007f3d24ab06ba llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM.so.19.1+0xeb06ba)
#1 0x00007f3d24aae264 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM.so.19.1+0xeae264)
#2 0x00007f3d24ab0d7b (/lib/x86_64-linux-gnu/libLLVM.so.19.1+0xeb0d7b)
#3 0x00007f3d23649df0 (/lib/x86_64-linux-gnu/libc.so.6+0x3fdf0)
#4 0x00005651bd8181c4 lld::wasm::TableSymbol::getTableNumber() const (/usr/bin/wasm-ld-19+0x4511c4)
#5 0x00005651bd839f3e lld::wasm::ElemSection::writeBody() (/usr/bin/wasm-ld-19+0x472f3e)
#6 0x00005651bd8264de (/usr/bin/wasm-ld-19+0x45f4de)
#7 0x00005651bd822220 (/usr/bin/wasm-ld-19+0x45b220)
#8 0x00005651bd8186fa lld::wasm::writeResult() (/usr/bin/wasm-ld-19+0x4516fa)
#9 0x00005651bd7fb5d9 (/usr/bin/wasm-ld-19+0x4345d9)
#10 0x00005651bd7f6ede lld::wasm::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/usr/bin/wasm-ld-19+0x42fede)
#11 0x00005651bd49d192 lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/usr/bin/wasm-ld-19+0xd6192)
#12 0x00005651bd49c41f lld_main(int, char**, llvm::ToolContext const&) (/usr/bin/wasm-ld-19+0xd541f)
#13 0x00005651bd49ca5a main (/usr/bin/wasm-ld-19+0xd5a5a)
#14 0x00007f3d23633ca8 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#15 0x00007f3d23633d65 call_init ./csu/../csu/libc-start.c:128:20
#16 0x00007f3d23633d65 __libc_start_main ./csu/../csu/libc-start.c:347:5
#17 0x00005651bd49c061 _start (/usr/bin/wasm-ld-19+0xd5061)
clang: error: unable to execute command: Segmentation fault
clang: error: linker command failed due to signal (use -v to see invocation)
owi: [DEBUG] clang failed: run ['/usr/bin/clang' '-O3' '--target=wasm32' '-m32' '-ffreestanding'
'--no-standard-libraries' '-Wno-everything' '-flto=thin'
'-Wl,--entry=main' '-Wl,--export=main' '-Wl,--lto-O0'
'-Wl,-z,stack-size=8388608' '-I'
'/home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files'
'-o' '/tmp/owi_c_ebc58a/a.out.wasm'
'/home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libc.wasm'
'/home/zapashcanon/dev/ml/owi/_build/install/default/share/owi/c_files/libowi.wasm'
'bench/testcomp/sv-benchmarks/c/hardware-verification-bv/btor2c-lazyMod.shift_register_top_w128_d8_e0.c']: exited with 1
owi: [ERROR] clang failed (run with -vv if the full error message is not displayed above)
I can provide more information if needed.
This is on:
$ wasm-ld --version
Debian LLD 19.1.7
The bug is not here on an older version:
$ wasm-ld --version
Ubuntu LLD 18.1.3
But there seems to be something strange in the older version too. The only thing I have in my C code is:
__attribute__((import_module("symbolic"), import_name("v128_symbol"))) __int128 owi_int128(void);
__attribute__((import_module("symbolic"), import_name("v128_symbol"))) unsigned __int128 owi_uint128(void);
But I am ending with the following Wasm import:
(type (;1;) (func (param i32)))
(import "symbolic" "v128_symbol" (func $owi_uint128 (type 1)))
Which is wrong (it should have type (func (result i32))
and not (func (param i32))
.