You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The value of a function argument is corrupted when a host component calls a function of a guest component. The signature of the function is foo: func(a: rec, b: rec, x4: u8, d: rec), where rec is defined as follows:
record rec {
x: s8,
f2: string,
}
The value of foo's third argument, x4, is corrupted and overwritten by the value of d.x. The host and guest components are compiled from Rust source programs using the wit-bindgen crate and the wasm32-wasip2 target. The two components implement the WIT worlds defined below:
Below are the Rust source programs of the host and guest components, respectively:
fnrun() -> Result<(),()>{let default_rec = Rec{x:0,// can be anythingf2:"".to_string(),// ^};let x4:u8 = 1;// this value should be printed, but isn't (can be anything)let special_rec = Rec{x: -1,// this field is magically converted to typeof(x4) and printed insteadf2:"".to_string(),// can be anything};println!("Sending: {x4}");foo(&default_rec,&default_rec,
x4,// prints x4&special_rec
);Ok(())}
Host and guest components are created from the source programs above using the Rust toolchain. The components are composed using wac. The resulting component is executed by Wasmtime. The value of x4 is printed before and after being passed as an argument to foo.
Notes:
Various modifications to the test case eliminate the unexpected behavior. For example, renaming the fields of rec, changing the number/types of foo's parameters, or renaming foo's third parameter can cause the printed values to match.
Additional context
The Rust source programs are derived from programs generated by a differential testing framework for wit-bindgen. The wit definitions are derived from a test case produced by wit-smith.
The text was updated successfully, but these errors were encountered:
The issue is that wit-bindgen generates variable names for its internal conversion code by appending numbers to identifiers.1 In this case this causes the x field in the d argument to be named x4 and the original x4 argument to be overwritten.
Description
The value of a function argument is corrupted when a host component calls a function of a guest component. The signature of the function is
foo: func(a: rec, b: rec, x4: u8, d: rec)
, where rec is defined as follows:The value of
foo
's third argument,x4
, is corrupted and overwritten by the value ofd.x
. The host and guest components are compiled from Rust source programs using thewit-bindgen
crate and thewasm32-wasip2
target. The two components implement the WIT worlds defined below:Below are the Rust source programs of the host and guest components, respectively:
Host and guest components are created from the source programs above using the Rust toolchain. The components are composed using
wac
. The resulting component is executed by Wasmtime. The value ofx4
is printed before and after being passed as an argument tofoo
.Steps to reproduce
Here is a zipped directory that reproduces the bug:
three_records_and_int_corruption.zip
three_records_and_int_corruption.zip
./verify.sh
Expected behavior
The printed values should match:
Actual behavior
The printed values don't match:
Notes:
Various modifications to the test case eliminate the unexpected behavior. For example, renaming the fields of
rec
, changing the number/types offoo
's parameters, or renamingfoo
's third parameter can cause the printed values to match.Additional context
The Rust source programs are derived from programs generated by a differential testing framework for wit-bindgen. The wit definitions are derived from a test case produced by wit-smith.
The text was updated successfully, but these errors were encountered: