jugglerchris added the bug label to Issue #8003.
jugglerchris opened issue #8003:
Test Case
A trivial component built with this wit (complete test at https://github.com/jugglerchris/wasmtime-index-error-test ; commit a129bcaf4207eb6b6d49f58c70e518cd91e65304 in case anything changes):
package comp:test; world w { export foo: interface { resource myres; make: func() -> myres; } }
and this host code:
let engine = Engine::new(&Config::new()).unwrap(); let linker = Linker::<()>::new(&engine); let component = Component::from_file(&engine, "target/comp.wasm").unwrap(); let component_ty = linker .substituted_component_type(&component) .unwrap(); let exports = component_ty.exports(); for (name, item) in exports { dbg!((name, &item)); match item { ComponentItem::ComponentInstance(instance) => { for item in instance.exports() { dbg!(item); } } _ => () } }
Steps to Reproduce
- First build the component (
make
in the above repo)- cargo run
Expected Results
The test program lists exports from the "foo" interface including the "make" function
Actual Results
A panic when iterating over the nested exports:
[src/main.rs:16:9] (name, &item) = ( "foo", ComponentInstance( ComponentInstance( Handle { index: TypeComponentInstanceIndex( 0, ), }, ), ), ) thread 'main' panicked at /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-18.0.1/src/runtime/component/types.rs:925:66: index out of bounds: the len is 0 but the index is 0
Versions and Environment
Wasmtime version or commit: 18.0.1
Operating system: Ubuntu 22.04.3
Architecture: amd64
Extra Info
I can't rule out me doing something dumb - I'm early in my WASM and Wasmtime journey - but I think an index OOB seems like an issue.
alexcrichton commented on issue #8003:
Definitely a bug in Wasmtime, thanks for the report! I'll try to take a look at this later this week.
fitzgen closed issue #8003:
Test Case
A trivial component built with this wit (complete test at https://github.com/jugglerchris/wasmtime-index-error-test ; commit a129bcaf4207eb6b6d49f58c70e518cd91e65304 in case anything changes):
package comp:test; world w { export foo: interface { resource myres; make: func() -> myres; } }
and this host code:
let engine = Engine::new(&Config::new()).unwrap(); let linker = Linker::<()>::new(&engine); let component = Component::from_file(&engine, "target/comp.wasm").unwrap(); let component_ty = linker .substituted_component_type(&component) .unwrap(); let exports = component_ty.exports(); for (name, item) in exports { dbg!((name, &item)); match item { ComponentItem::ComponentInstance(instance) => { for item in instance.exports() { dbg!(item); } } _ => () } }
Steps to Reproduce
- First build the component (
make
in the above repo)- cargo run
Expected Results
The test program lists exports from the "foo" interface including the "make" function
Actual Results
A panic when iterating over the nested exports:
[src/main.rs:16:9] (name, &item) = ( "foo", ComponentInstance( ComponentInstance( Handle { index: TypeComponentInstanceIndex( 0, ), }, ), ), ) thread 'main' panicked at /home/chris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-18.0.1/src/runtime/component/types.rs:925:66: index out of bounds: the len is 0 but the index is 0
Versions and Environment
Wasmtime version or commit: 18.0.1
Operating system: Ubuntu 22.04.3
Architecture: amd64
Extra Info
I can't rule out me doing something dumb - I'm early in my WASM and Wasmtime journey - but I think an index OOB seems like an issue.
jugglerchris commented on issue #8003:
Thanks for the quick fix! Looks good on main now.
Last updated: Dec 23 2024 at 12:05 UTC