Repository navigation
Closed
Description
Describe the bug
The attached test cases cause out of bounds or integer overflow traps. But in the trap handler code, a stack-buffer-underflow occurs.
$> wasmer -vV; rustc -vV
wasmer 7.2.0-alpha.1
binary: wasmer-cli
commit-hash: 89ce1989711550e0212592943defae9500b4e2a7
commit-date: 2026-04-19
host: x86_64-unknown-linux-gnu
CPU flags: sse2 sse3 ssse3 sse4.1 sse4.2 popcnt avx bmi bmi2 avx2 avx512dq avx512vl avx512f lzcnt fma
runtimes: Singlepass, Cranelift, LLVM
features: wasix
rustc 1.97.0-nightly (0febdbab2 2026-04-18)
binary: rustc
commit-hash: 0febdbab2720dc0360cd294c67db88d6d06580d4
commit-date: 2026-04-18
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2Steps to reproduce
- Convert the following PoC to wasm and run in LLVM mode:
(module
(memory (;0;) 1)
(export "_start" (func 0))
(func (;0;) (result i64)
i32.const 1
i64.load16_s offset=65535 align=1
)
)
- Convert the following PoC to wasm and run in Cranelift/Singlepass mode:
(module
(export "_start" (func $main))
(func $main (;0;) (result i32)
f64.const 0x1.d6329f1c35ca5p+132
i32.trunc_f64_s
)
)
Actual behavior
==87549==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x1154151e2e98 at pc 0x555559576e8e bp 0x1154151e2e70 sp 0x1154151e2630
WRITE of size 40 at 0x1154151e2e98 thread T0
#0 0x555559576e8d in __asan_memcpy /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:65:3
#1 0x55555fd1c6fd in core::ptr::read::<<wasmer_vm::trap::traphandlers::TrapHandlerContextInner<()>>::handle_trap::{closure#1}> .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1720:9
#2 0x55555fd1c6fd in <*mut <wasmer_vm::trap::traphandlers::TrapHandlerContextInner<()>>::handle_trap::{closure#1}>::read .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mut_ptr.rs:1263:18
#3 0x55555fd1c6fd in <corosensei::trap::CoroutineTrapHandler<_>>::setup_trap_handler::trap_handler::<<wasmer_vm::trap::traphandlers::TrapHandlerContextInner<()>>::handle_trap::{closure#1}, core::result::Result<(), wasmer_vm::trap::traphandlers::UnwindReason>> .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/corosensei-0.3.3/src/trap.rs:89:68
#4 0x55555fd310ad in stack_init_trampoline (wasmer/target/x86_64-unknown-linux-gnu/release/wasmer+0xa7dd0ad) (BuildId: 6c0a1a7d893befbfb8e9716e808c0f072009aeab)
#5 0x55555fcf8a65 in corosensei::arch::x86_64::switch_and_link .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/corosensei-0.3.3/src/unwind.rs:138:17
#6 0x55555fcf8a65 in <corosensei::coroutine::Coroutine<(), wasmer_vm::trap::traphandlers::UnwindReason, core::result::Result<(), wasmer_vm::trap::traphandlers::UnwindReason>, &mut corosensei::stack::unix::DefaultStack>>::resume_inner .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/corosensei-0.3.3/src/coroutine.rs:320:35
#7 0x55555fcf8a65 in <corosensei::coroutine::Coroutine<(), wasmer_vm::trap::traphandlers::UnwindReason, core::result::Result<(), wasmer_vm::trap::traphandlers::UnwindReason>, &mut corosensei::stack::unix::DefaultStack>>::resume .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/corosensei-0.3.3/src/coroutine.rs:298:24
#8 0x55555fd1a49e in <corosensei::scoped::ScopedCoroutineRef<(), wasmer_vm::trap::traphandlers::UnwindReason, core::result::Result<(), wasmer_vm::trap::traphandlers::UnwindReason>, &mut corosensei::stack::unix::DefaultStack>>::resume .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/corosensei-0.3.3/src/scoped.rs:200:20
#9 0x55555fd1a49e in wasmer_vm::trap::traphandlers::on_wasm_stack::<wasmer_vm::trap::traphandlers::wasmer_call_trampoline::{closure#0}, ()>::{closure#4}::{closure#0} wasmer/lib/vm/src/trap/traphandlers.rs:1079:28
#10 0x55555fd1a49e in <wasmer_vm::trap::traphandlers::TrapHandlerContext>::install::<(), core::result::Result<(), wasmer_vm::trap::traphandlers::UnwindReason>, wasmer_vm::trap::traphandlers::on_wasm_stack<wasmer_vm::trap::traphandlers::wasmer_call_trampoline::{closure#0}, ()>::{closure#4}::{closure#0}> wasmer/lib/vm/src/trap/traphandlers.rs:906:9
#11 0x55555fd081e2 in wasmer_vm::trap::traphandlers::on_wasm_stack::<wasmer_vm::trap::traphandlers::wasmer_call_trampoline::{closure#0}, ()>::{closure#4} wasmer/lib/vm/src/trap/traphandlers.rs:1078:9
#12 0x55555fd081e2 in <corosensei::scoped::ScopedCoroutine<(), wasmer_vm::trap::traphandlers::UnwindReason, core::result::Result<(), wasmer_vm::trap::traphandlers::UnwindReason>, &mut corosensei::stack::unix::DefaultStack>>::scope::<wasmer_vm::trap::traphandlers::on_wasm_stack<wasmer_vm::trap::traphandlers::wasmer_call_trampoline::{closure#0}, ()>::{closure#4}, core::result::Result<(), wasmer_vm::trap::traphandlers::UnwindReason>> .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/corosensei-0.3.3/src/scoped.rs:154:9
#13 0x55555fd1f0e0 in wasmer_vm::trap::traphandlers::on_wasm_stack::<wasmer_vm::trap::traphandlers::wasmer_call_trampoline::{closure#0}, ()> wasmer/lib/vm/src/trap/traphandlers.rs:1075:10
#14 0x55555fd1f0e0 in wasmer_vm::trap::traphandlers::catch_traps::<wasmer_vm::trap::traphandlers::wasmer_call_trampoline::{closure#0}, ()> wasmer/lib/vm/src/trap/traphandlers.rs:823:5
#15 0x55555fd1f0e0 in wasmer_vm::trap::traphandlers::wasmer_call_trampoline wasmer/lib/vm/src/trap/traphandlers.rs:791:9
#16 0x55555a530ad8 in <wasmer::backend::sys::entities::function::Function>::call_wasm_raw::<wasmer::entities::store::Store> wasmer/lib/api/src/backend/sys/entities/function/mod.rs:543:21
#17 0x55555a530ad8 in <wasmer::backend::sys::entities::function::Function>::call_wasm::<wasmer::entities::store::Store> wasmer/lib/api/src/backend/sys/entities/function/mod.rs:504:14
#18 0x55555a530ad8 in <wasmer::backend::sys::entities::function::Function>::call::<wasmer::entities::store::Store> wasmer/lib/api/src/backend/sys/entities/function/mod.rs:610:14
#19 0x5555599a300e in <wasmer::entities::function::inner::BackendFunction>::call::<wasmer::entities::store::Store> wasmer/lib/api/src/entities/function/inner.rs:504:15
#20 0x5555599a300e in <wasmer::entities::function::Function>::call::<wasmer::entities::store::Store> wasmer/lib/api/src/entities/function/mod.rs:331:16
#21 0x5555599a300e in wasmer_cli::commands::run::invoke_function wasmer/lib/cli/src/commands/run/mod.rs:772:13
#22 0x5555599a300e in <wasmer_cli::commands::run::Run>::execute_pure_wasm_module wasmer/lib/cli/src/commands/run/mod.rs:608:22
#23 0x5555599a300e in <wasmer_cli::commands::run::Run>::execute_wasm wasmer/lib/cli/src/commands/run/mod.rs:412:18
#24 0x5555599ac54c in <wasmer_cli::commands::run::Run>::execute_inner (.llvm.6815501634825132108) wasmer/lib/cli/src/commands/run/mod.rs:323:27
#25 0x5555599b1765 in <wasmer_cli::commands::run::Run>::execute wasmer/lib/cli/src/commands/run/mod.rs:176:27
#26 0x55555a5f8896 in <wasmer_cli::commands::WasmerCmd>::execute wasmer/lib/cli/src/commands/mod.rs:177:48
#27 0x55555a5f8896 in <wasmer_cli::commands::WasmerCmd>::run_inner (.llvm.16487548056635071903) wasmer/lib/cli/src/commands/mod.rs:296:30
#28 0x55555a5f3745 in <wasmer_cli::commands::WasmerCmd>::run wasmer/lib/cli/src/commands/mod.rs:236:29
#29 0x5555596945c5 in wasmer_cli::run_cli wasmer/lib/cli/src/lib.rs:41:5
#30 0x5555595a7832 in <fn() as core::ops::function::FnOnce<()>>::call_once .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
#31 0x5555595a7832 in std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()> .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:166:18
#32 0x5555595a7858 in std::rt::lang_start::<()>::{closure#0} .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:206:18
#33 0x5555613d7e86 in <&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe as core::ops::function::FnOnce<()>>::call_once /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/core/src/ops/function.rs:287:21
#34 0x5555613d7e86 in std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32> /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/panicking.rs:581:40
#35 0x5555613d7e86 in std::panicking::catch_unwind::<i32, &dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe> /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/panicking.rs:544:19
#36 0x5555613d7e86 in std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32> /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/panic.rs:359:14
#37 0x5555613d7e86 in std::rt::lang_start_internal::{closure#0} /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/rt.rs:175:24
#38 0x5555613d7e86 in std::panicking::catch_unwind::do_call::<std::rt::lang_start_internal::{closure#0}, isize> /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/panicking.rs:581:40
#39 0x5555613d7e86 in std::panicking::catch_unwind::<isize, std::rt::lang_start_internal::{closure#0}> /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/panicking.rs:544:19
#40 0x5555613d7e86 in std::panic::catch_unwind::<std::rt::lang_start_internal::{closure#0}, isize> /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/panic.rs:359:14
#41 0x5555613d7e86 in std::rt::lang_start_internal /rustc/0febdbab2720dc0360cd294c67db88d6d06580d4/library/std/src/rt.rs:171:5
#42 0x5555595a797f in main (wasmer/target/x86_64-unknown-linux-gnu/release/wasmer+0x405397f) (BuildId: 6c0a1a7d893befbfb8e9716e808c0f072009aeab)
#43 0x155555229d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 095c7ba148aeca81668091f718047078d57efddb)
#44 0x155555229e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId: 095c7ba148aeca81668091f718047078d57efddb)
#45 0x5555594eab64 in _start (wasmer/target/x86_64-unknown-linux-gnu/release/wasmer+0x3f96b64) (BuildId: 6c0a1a7d893befbfb8e9716e808c0f072009aeab)
Metadata
Metadata
Assignees
Labels
No labels
Activity
marxin commentedon Apr 29, 2026
Thanks for the report, will take a look at it.
marxin commentedon Nov 13, 2026
sanitizerfeature must be enabled inlib/apiin order to enablesanitizerfeature in thecorosenseicrate.