@@ -293,3 +293,52 @@ fn core_dump_with_shared_memory() -> Result<()> {
293293
294294 Ok ( ( ) )
295295}
296+
297+ #[ test]
298+ #[ cfg_attr( miri, ignore) ]
299+ fn coredump_with_composed_component_adapters ( ) -> Result < ( ) > {
300+ use wasmtime:: component:: { Component , Linker } ;
301+
302+ let mut config = Config :: new ( ) ;
303+ config. coredump_on_trap ( true ) ;
304+ let engine = Engine :: new ( & config) ?;
305+ let component = Component :: new (
306+ & engine,
307+ r#"
308+ (component
309+ (component $A
310+ (core module $m
311+ (func (export "f") (param i32) (result i32) unreachable)
312+ )
313+ (core instance $i (instantiate $m))
314+ (func (export "f") (param "x" u32) (result u32)
315+ (canon lift (core func $i "f")))
316+ )
317+ (component $B
318+ (import "f" (func $f (param "x" u32) (result u32)))
319+ (core func $fl (canon lower (func $f)))
320+ (core module $m
321+ (import "" "f" (func $f (param i32) (result i32)))
322+ (func (export "run") (call $f (i32.const 1)) drop)
323+ )
324+ (core instance $i (instantiate $m
325+ (with "" (instance (export "f" (func $fl))))))
326+ (func (export "run") (canon lift (core func $i "run")))
327+ )
328+ (instance $a (instantiate $A))
329+ (instance $b (instantiate $B (with "f" (func $a "f"))))
330+ (func (export "run") (alias export $b "run"))
331+ )
332+ "# ,
333+ ) ?;
334+ let mut store = Store :: new ( & engine, ( ) ) ;
335+ let instance = Linker :: new ( & engine) . instantiate ( & mut store, & component) ?;
336+ let run = instance. get_typed_func :: < ( ) , ( ) > ( & mut store, "run" ) ?;
337+
338+ let err = run. call ( & mut store, ( ) ) . unwrap_err ( ) ;
339+ let coredump = err. downcast_ref :: < WasmCoreDump > ( ) . unwrap ( ) ;
340+ let bytes = coredump. serialize ( & mut store, "composed-component-adapters" ) ;
341+ wasmparser:: Validator :: new ( ) . validate_all ( & bytes) ?;
342+
343+ Ok ( ( ) )
344+ }
0 commit comments