Symbolize start trap traces (#1437)
Make sure we've registered the frame info early enough so traps during instantiation give frames as well.
This commit is contained in:
@@ -123,6 +123,7 @@ impl Instance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.register_frame_info();
|
||||||
let config = store.engine().config();
|
let config = store.engine().config();
|
||||||
let instance_handle = instantiate(
|
let instance_handle = instantiate(
|
||||||
config,
|
config,
|
||||||
@@ -141,7 +142,6 @@ impl Instance {
|
|||||||
export,
|
export,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
module.register_frame_info();
|
|
||||||
Ok(Instance {
|
Ok(Instance {
|
||||||
instance_handle,
|
instance_handle,
|
||||||
module: module.clone(),
|
module: module.clone(),
|
||||||
|
|||||||
@@ -361,3 +361,36 @@ fn call_signature_mismatch() -> Result<()> {
|
|||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn start_trap_pretty() -> Result<()> {
|
||||||
|
let store = Store::default();
|
||||||
|
let wat = r#"
|
||||||
|
(module $m
|
||||||
|
(func $die unreachable)
|
||||||
|
(func call $die)
|
||||||
|
(func $foo call 1)
|
||||||
|
(func $start call $foo)
|
||||||
|
(start $start)
|
||||||
|
)
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let module = Module::new(&store, wat)?;
|
||||||
|
let e = match Instance::new(&module, &[]) {
|
||||||
|
Ok(_) => panic!("expected failure"),
|
||||||
|
Err(e) => e.downcast::<Trap>()?,
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
e.to_string(),
|
||||||
|
"\
|
||||||
|
wasm trap: unreachable, source location: @001d
|
||||||
|
wasm backtrace:
|
||||||
|
0: m!die
|
||||||
|
1: m!<wasm function 1>
|
||||||
|
2: m!foo
|
||||||
|
3: m!start
|
||||||
|
"
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user