-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pulley: Execute a wasm module under miri (#10096)
* pulley: Execute a wasm module under miri This commit adds a test to CI and a script locally to execute which will run an entire wasm module under Pulley. The goal of this commit is to add The Test for miri execution of wasm. In general miri is too slow to run for the full test suite and even for this single test it takes a very long time to compile the one small module here. To help with this the module is precompiled on native for Pulley and then deserialized in miri itself, meaning that we skip miri execution of Cranelift entirely. The goal of this commit is to eventually expand this test to cover lots of little and basic operations of wasm which touch VM state. For now it's just a simple smoke test that doesn't run much but it will be expanded over time. Making it much larger than now already turns up miri violations so I wanted to land an initial scaffold first before expanding later. Getting this test to pass requires changing the `VmPtr<T>` introduced in #10043 to use a `NonZeroUsize` internally rather than `NonNull<T>`. This is because Pulley is only compatible with exposed provenance which means we need to actually expose the provenance of pointers. Both Pulley and Wasmtime need to deal with exposed provenance APIs, but such APIs are not available in Wasmtime's current MSRV of 1.82. These APIs were instead introduced as stable in Rust 1.84. In lieu of waiting a few months because I'm impatient I've added a small build script to both crates to detect the rustc version and see whether provenance APIs are available. These build script modifications will no longer be necessary once our MSRV is 1.84+. prtest:miri * Rejigger the CI matrix * Don't hardcode toolchain in script
- Loading branch information
1 parent
8a96989
commit 887e5c9
Showing
13 changed files
with
237 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# This is a small script to assist in running the `pulley_provenance_test` test | ||
# located at `tests/all/pulley.rs`. The goal of this script is to use the native | ||
# host to compile the wasm module in question to avoid needing to run Cranelift | ||
# under MIRI. That enables much faster iteration on the test here. | ||
|
||
set -ex | ||
|
||
cargo run --no-default-features --features compile,pulley,wat,gc-drc,component-model \ | ||
compile --target pulley64 ./tests/all/pulley_provenance_test.wat \ | ||
-o tests/all/pulley_provenance_test.cwasm \ | ||
-O memory-reservation=$((1 << 20)) \ | ||
-O memory-guard-size=0 \ | ||
-O signals-based-traps=n | ||
|
||
MIRIFLAGS="$MIRIFLAGS -Zmiri-disable-isolation -Zmiri-permissive-provenance" \ | ||
cargo miri test --test all -- \ | ||
--ignored pulley_provenance_test "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::process::Command; | ||
use std::str; | ||
|
||
fn main() { | ||
// Temporary check to see if the rustc version >= 1.84 in which case | ||
// provenance-related pointer APIs are available. This is temporary because | ||
// in the future the MSRV of this crate will be beyond 1.84 in which case | ||
// this build script can be deleted. | ||
let minor = rustc_minor_version().unwrap_or(0); | ||
if minor >= 84 { | ||
println!("cargo:rustc-cfg=has_provenance_apis"); | ||
} | ||
println!("cargo:rustc-check-cfg=cfg(has_provenance_apis)"); | ||
} | ||
|
||
fn rustc_minor_version() -> Option<u32> { | ||
let rustc = std::env::var("RUSTC").unwrap(); | ||
let output = Command::new(rustc).arg("--version").output().ok()?; | ||
let version = str::from_utf8(&output.stdout).ok()?; | ||
let mut pieces = version.split('.'); | ||
if pieces.next() != Some("rustc 1") { | ||
return None; | ||
} | ||
pieces.next()?.parse().ok() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.