wasmerio/wasmer · critical · panic
not implemented
Error message
not implemented
What it means
Trap::to_trap is a stub: its body is a bare unimplemented!(), so calling it panics with "not implemented" every time. The method is documented to return Option<TrapCode> if the Trap carries a trap code, but that logic was never written. Any caller relying on it to classify a trap hits an unconditional panic, independent of the Trap variant (signal_trap, lib, etc.).
Source
Thrown at lib/vm/src/trap/trap.rs:80
/// Internally saves a backtrace when constructed.
pub fn user(err: Box<dyn Error + Send + Sync>) -> Self {
Self::User(err)
}
/// Construct a new Wasm trap with the given source location and backtrace.
///
/// Internally saves a backtrace when constructed.
pub fn wasm(pc: usize, backtrace: Backtrace, signal_trap: Option<TrapCode>) -> Self {
Self::Wasm {
pc,
backtrace,
signal_trap,
}
}
/// Returns trap code, if it's a Trap
pub fn to_trap(self) -> Option<TrapCode> {
unimplemented!()
}
/// Construct a new Wasm trap with the given trap code.
///
/// Internally saves a backtrace when constructed.
pub fn lib(trap_code: TrapCode) -> Self {
let backtrace = Backtrace::new_unresolved();
Self::Lib {
trap_code,
backtrace,
}
}
/// Construct a new OOM trap with the given source location and trap code.
///
/// Internally saves a backtrace when constructed.
pub fn oom() -> Self {
let backtrace = Backtrace::new_unresolved();View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Do not call to_trap; inspect the Trap variant directly and map signal-based traps to TrapCode yourself.
- Implement to_trap locally: match the internal enum (e.g. Trap::Lib { trap_code, .. } => Some(trap_code), _ => None).
- Use the library's existing trap-code accessor/APIs (e.g. Trap::lib / downcast helpers) instead.
- File/patch upstream: the method body is an unfinished stub.
Example fix
// before
let code = trap.to_trap(); // panics: unimplemented!()
// after (local helper)
fn trap_code_of(trap: &Trap) -> Option<TrapCode> {
match trap {
Trap::Lib { trap_code, .. } => Some(*trap_code),
_ => None,
}
} Defensive patterns
Strategy: type-guard
Type guard
// narrow Trap variants yourself instead of calling to_trap()
fn trap_code_of(trap: &Trap) -> Option<TrapCode> {
match trap {
Trap::Lib { trap_code, .. } => Some(*trap_code),
_ => None,
}
} Try / catch
let code = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| trap.to_trap()))
.ok()
.flatten()
.or_else(|| trap_code_of(&trap)); Prevention
- Never call stub methods marked unimplemented!; inspect the enum directly
- Grep the dependency for unimplemented! before adopting an API
- Write unit tests exercising trap classification so stubs fail fast in CI
When it happens
Trigger: Any call to Trap::to_trap() — e.g. code converting a raised Trap into a TrapCode when handling a wasm fault — panics immediately regardless of input.
Common situations: Embedder code classifying runtime faults (e.g. turning SIGSEGV-derived traps into TrapCode::MemoryOutOfBounds), custom host integrations, or ported code from wasmer versions where to_trap was implemented.
Related errors
- dwarf relocation size for personality not supported: {}
- dwarf relocation size for LSDA not supported: {}
- eh pointer encoding {eh_pe:?} not supported for symbol targe
- write_offset not yet implemented
- write_offset_at not yet implemented
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/27cb73f292bbdb90.
Report an issue: GitHub.