Stream: git-wasmtime

Topic: wasmtime / issue #8003 Index out of bounds when iterating...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 27 2024 at 23:00):

jugglerchris added the bug label to Issue #8003.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 27 2024 at 23:00):

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

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.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 28 2024 at 20:02):

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.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 29 2024 at 19:19):

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

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.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 01 2024 at 07:01):

jugglerchris commented on issue #8003:

Thanks for the quick fix! Looks good on main now.


Last updated: Nov 22 2024 at 16:03 UTC