-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugIncorrect behavior in the current implementation that needs fixingIncorrect behavior in the current implementation that needs fixing
Description
When I try to instantiate a WASM module that contains a very large function, and cranelift is configure to use optimizations (wasmtime::OptLevel::Speed or wasmtime::OptLevel::SpeedAndSize), it panics with:
thread '<unnamed>' panicked at /Users/vmalvarez/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cranelift-codegen-0.123.2/src/ir/instructions.rs:228:9:
assertion failed: payload < (1 << 30)
stack backtrace:
0: 0x105ae8298 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc62d1c602f32d045
1: 0x105b06898 - core::fmt::write::hec54c1d5587662ba
2: 0x105ae55c4 - std::io::Write::write_fmt::h32cb3f1ee5943fae
3: 0x105ae814c - std::sys::backtrace::BacktraceLock::print::hbdf74b1541f6a1ff
4: 0x105ae9914 - std::panicking::default_hook::{{closure}}::h5448a63c4ecd0e4e
5: 0x105ae976c - std::panicking::default_hook::ha395121f3118f99a
6: 0x104cca9ec - yr::main::{{closure}}::hfe5d5caf9c5c3c1f
7: 0x105aea3d8 - std::panicking::rust_panic_with_hook::h2cf6c7b76a1ec3f1
8: 0x105ae9fa8 - std::panicking::begin_panic_handler::{{closure}}::hb6df43c194981807
9: 0x105ae8750 - std::sys::backtrace::__rust_end_short_backtrace::h870816de405e4980
10: 0x105ae9cac - __rustc[e402ec7dbc433fa7]::rust_begin_unwind
11: 0x105b84214 - core::panicking::panic_fmt::hae8dacf72a638e20
12: 0x105b84284 - core::panicking::panic::hc324204614143dd3
13: 0x1056ee7fc - cranelift_codegen::ir::instructions::InstructionData::map_values::h0278140030621a4a
14: 0x1056fd830 - cranelift_codegen::egraph::EgraphPass::run::h63605c10fdb90cc5
15: 0x1056a35bc - cranelift_codegen::context::Context::optimize::h4483eab5301b4a42
16: 0x1056a2f60 - cranelift_codegen::context::Context::compile_stencil::ha8e37d40161c2624
17: 0x1056a3910 - cranelift_codegen::context::Context::compile::h81a4bb0e1cd3db9e
18: 0x10543dbec - wasmtime_internal_cranelift::compiler::FunctionCompiler::finish_with_info::hc96d5e0ca4268141
19: 0x10543c7cc - <wasmtime_internal_cranelift::compiler::Compiler as wasmtime_environ::compile::InliningCompiler>::finish_compiling::h7532ff7544c0367b
If I disable optimizations (with wasmtime::OptLevel::None), the panic disappears and I get this error from wasmtime::Module::from_binary:
Compilation error: Code for function is too large
My expectation was that wasmtime returns an error when you try to instantiate a module that contains very large functions, no matter the optimization level you choose for cranelift.
I'm attaching WASM module in binary form that triggers this issue.
Versions and Environment
Wasmtime version or commit: 36.0.2
Operating system: Linux, macOS
Architecture: x86_64, aarch64
Metadata
Metadata
Assignees
Labels
bugIncorrect behavior in the current implementation that needs fixingIncorrect behavior in the current implementation that needs fixing