- What are the steps to reproduce the issue?
t.wasm is wat2wasm from below text:
(module
(func $add (param $lhs i32) (param $rhs i32) (result i32)
get_local $lhs
get_local $rhs
i32.add)
(export "add" (func $add))
)
./wasmtime run --lightbeam t.wasm 1 2
./wasmtime wasm2obj --lightbeam t.wasm t.obj
- What do you expect to happen? What does actually happen? Does it panic, and
if so, with which assertion?
Expect to be run without any issue. Got error with the output:
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /PATH/wasmtime/crates/lightbeam/src/backend.rs:637:35
note: run withRUST_BACKTRACE=1environment variable to display a backtrace
- Which Wasmtime version / commit hash / branch are you using?
main latest by now, commit 12e658a1ef344ccacf872accb0cadd7ef6e8cf4a
- If relevant, can you include some extra information about your environment?
(Rust version, operating system, architecture...)
rustc 1.45.2, MacOS
The panic happens at https://github.com/bytecodealliance/wasmtime/blob/12e658a1ef344ccacf872accb0cadd7ef6e8cf4a/crates/lightbeam/src/backend.rs#L637
func_starts should be filled at https://github.com/bytecodealliance/wasmtime/blob/12e658a1ef344ccacf872accb0cadd7ef6e8cf4a/crates/lightbeam/src/backend.rs#L610-L612
func_count gets it's value from https://github.com/bytecodealliance/wasmtime/blob/77827a48a924337b3b690d8f35aef0f601af6dde/crates/lightbeam/wasmtime/src/lib.rs#L38-L42
All elements in function_body_inputs are taken just before at https://github.com/bytecodealliance/wasmtime/blob/77827a48a924337b3b690d8f35aef0f601af6dde/crates/jit/src/compiler.rs#L131 leaving the count at zero.
The lightbeam backend is known to currently have many bugs in it and is not tested on CI. It's not recommended for widespread usage. Thanks for the report, though, this is good to know when someone gets around to fixing lightbeam issues!
Are the lengths of translation.function_body_input and translation.native_signatures always the same or can they be different in some situations?