Stream: git-wasmtime

Topic: wasmtime / issue #7951 Weired utf8 parsing error.


view this post on Zulip Wasmtime GitHub notifications bot (Feb 16 2024 at 12:57):

MendyBerger added the bug label to Issue #7951.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 16 2024 at 12:57):

MendyBerger opened issue #7951:

This issue is a weird one. There seems to be some very specific set of inputs that trigger a utf8 parsing error, and modifying the inputs even just a little can stop it from happening. This was really hard to get to reproduce reliably.

I ran into this issue twice, and this is my smallest reproduction that triggers it. Sorry if it's too convoluted, don't know how to make it smaller, and already spent quite a few hours on it.

Test Case

https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/wasm/out.wasm

Steps to Reproduce

Clone the repo at https://github.com/MendyBerger/wasmtime-utf8-parsing-error.
Compile the wasm module.
Run with the runtime.

Here's a list of commnads

# clone the repo
git clone https://github.com/MendyBerger/wasmtime-utf8-parsing-error
cd wasmtime-utf8-parsing-error

# compile the wasm module
cd wasm
cargo build --release --target wasm32-unknown-unknown
wasm-tools component new ./target/wasm32-unknown-unknown/release/wasm.wasm -o out.wasm

# run the runtime
cd ../runtime
cargo run

Expected Results

Expect it to just run.

Actual Results

Fails with the following error:

Error: error while executing at wasm backtrace:
    0: 0x1596ef - wit-component:shim!indirect-$root-my-func
    1:  0x4ab - <unknown>!run
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information

Caused by:
    invalid utf-8 sequence of 1 bytes from index 0

Versions and Environment

Wasmtime version or commit: 17.0.1

Operating system: Ubuntu

Architecture: x86

Extra Info

Some of the weirdness:

view this post on Zulip Wasmtime GitHub notifications bot (Feb 16 2024 at 12:59):

MendyBerger edited issue #7951:

This issue is a weird one. There seems to be some very specific set of inputs that trigger a utf8 parsing error, and modifying the inputs even just a little can stop it from happening. This was really hard to get to reproduce reliably.

I ran into this issue twice, and this is my smallest reproduction that triggers it. Sorry if it's too convoluted, don't know how to make it smaller, and already spent quite a few hours on it.

Test Case

https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/wasm/out.wasm

Steps to Reproduce

Clone the repo at https://github.com/MendyBerger/wasmtime-utf8-parsing-error.
Compile the wasm module.
Run with the runtime.

Here's a list of commands

# clone the repo
git clone https://github.com/MendyBerger/wasmtime-utf8-parsing-error
cd wasmtime-utf8-parsing-error

# compile the wasm module
cd wasm
cargo build --release --target wasm32-unknown-unknown
wasm-tools component new ./target/wasm32-unknown-unknown/release/wasm.wasm -o out.wasm

# run the runtime
cd ../runtime
cargo run

Expected Results

Expect it to just run.

Actual Results

Fails with the following error:

Error: error while executing at wasm backtrace:
    0: 0x1596ef - wit-component:shim!indirect-$root-my-func
    1:  0x4ab - <unknown>!run
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information

Caused by:
    invalid utf-8 sequence of 1 bytes from index 0

Versions and Environment

Wasmtime version or commit: 17.0.1

Operating system: Ubuntu

Architecture: x86

Extra Info

Some of the weirdness:

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

MendyBerger edited issue #7951:

This issue is a weird one. There seems to be some very specific set of inputs that trigger a utf8 parsing error, and modifying the inputs even just a little can stop it from happening. This was really hard to get to reproduce reliably.

I ran into this issue twice, and this is my smallest reproduction that triggers it. Sorry if it's too convoluted, don't know how to make it smaller, and already spent quite a few hours on it.

Test Case

Wasm input:
https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/wasm/src/lib.rs

Actual wasm:
https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/wasm/out.wasm

Runtime code:
https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/runtime/src/main.rs

Steps to Reproduce

Clone the repo at https://github.com/MendyBerger/wasmtime-utf8-parsing-error.
Compile the wasm module.
Run with the runtime.

Here's a list of commands

# clone the repo
git clone https://github.com/MendyBerger/wasmtime-utf8-parsing-error
cd wasmtime-utf8-parsing-error

# compile the wasm module
cd wasm
cargo build --release --target wasm32-unknown-unknown
wasm-tools component new ./target/wasm32-unknown-unknown/release/wasm.wasm -o out.wasm

# run the runtime
cd ../runtime
cargo run

Expected Results

Expect it to just run.

Actual Results

Fails with the following error:

Error: error while executing at wasm backtrace:
    0: 0x1596ef - wit-component:shim!indirect-$root-my-func
    1:  0x4ab - <unknown>!run
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information

Caused by:
    invalid utf-8 sequence of 1 bytes from index 0

Versions and Environment

Wasmtime version or commit: 17.0.1

Operating system: Ubuntu

Architecture: x86

Extra Info

Some of the weirdness:

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

alexcrichton commented on issue #7951:

Thanks for the report, and very much appreciate the work put in to minimizing this! Looking at the code I haven't reproduce this exactly just yet but I suspect you're running into https://github.com/bytecodealliance/wit-bindgen/issues/817 where this is a bug in the guest generated code where there's UB in the rust/wasm layer, which I think could explain why you're seeing such surprising behavior here.

I'll try to see if I can fix that issue soon and see if it fixes this as well

view this post on Zulip Wasmtime GitHub notifications bot (Feb 16 2024 at 17:21):

MendyBerger commented on issue #7951:

Thanks!! I'll keep an eye on that one.

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

alexcrichton commented on issue #7951:

Ok I've confirmed that your issue should be fixed by https://github.com/bytecodealliance/wit-bindgen/pull/846, so I think it was indeed that wit-bindgen issue.

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

MendyBerger commented on issue #7951:

@alexcrichton thanks so much!!! I super appreciate how quickly you did this!

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

alexcrichton closed issue #7951:

This issue is a weird one. There seems to be some very specific set of inputs that trigger a utf8 parsing error, and modifying the inputs even just a little can stop it from happening. This was really hard to get to reproduce reliably.

I ran into this issue twice, and this is my smallest reproduction that triggers it. Sorry if it's too convoluted, don't know how to make it smaller, and already spent quite a few hours on it.

Test Case

Wasm input:
https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/wasm/src/lib.rs

Actual wasm:
https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/wasm/out.wasm

Runtime code:
https://github.com/MendyBerger/wasmtime-utf8-parsing-error/blob/main/runtime/src/main.rs

Steps to Reproduce

Clone the repo at https://github.com/MendyBerger/wasmtime-utf8-parsing-error.
Compile the wasm module.
Run with the runtime.

Here's a list of commands

# clone the repo
git clone https://github.com/MendyBerger/wasmtime-utf8-parsing-error
cd wasmtime-utf8-parsing-error

# compile the wasm module
cd wasm
cargo build --release --target wasm32-unknown-unknown
wasm-tools component new ./target/wasm32-unknown-unknown/release/wasm.wasm -o out.wasm

# run the runtime
cd ../runtime
cargo run

Expected Results

Expect it to just run.

Actual Results

Fails with the following error:

Error: error while executing at wasm backtrace:
    0: 0x1596ef - wit-component:shim!indirect-$root-my-func
    1:  0x4ab - <unknown>!run
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information

Caused by:
    invalid utf-8 sequence of 1 bytes from index 0

Versions and Environment

Wasmtime version or commit: 17.0.1

Operating system: Ubuntu

Architecture: x86

Extra Info

Some of the weirdness:


Last updated: Nov 22 2024 at 17:03 UTC