Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Remove differential fuzzing with the spec interpreter (#15122)

Alex Crichtonb112f2f24a58
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 1114eeb822..0a47eaaca1 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -325,8 +325,6 @@ jobs:
--exclude test-programs-artifacts \
--exclude cranelift-codegen-meta \
--exclude wasmtime-wasi-nn \
- --exclude wasmtime-fuzzing \
- --exclude wasm-spec-interpreter \
--exclude calculator \
--all-features
- run: cargo doc --package cranelift-codegen-meta --document-private-items
@@ -559,8 +557,6 @@ jobs:
--exclude test-programs-artifacts \
--exclude wasmtime-wasi-nn \
--exclude wasmtime-wasi-tls \
- --exclude wasmtime-fuzzing \
- --exclude wasm-spec-interpreter \
--exclude cranelift-isle-veri \
--exclude calculator \
--exclude wasi-preview1-component-adapter
@@ -758,16 +754,10 @@ jobs:
- run: test -f report/index.html
# Ensure that fuzzers still build.
- #
- # Install the OCaml packages necessary for fuzz targets that use the
- # `wasm-spec-interpreter`.
- uses: ./.github/actions/cargo-install
with:
crate: cargo-fuzz
version: 0.13.2
- - uses: ./.github/actions/apt-get-install
- with:
- packages: ocaml-nox ocamlbuild ocaml-findlib libzarith-ocaml-dev
- run: cargo fuzz check --dev --features fuzz-xed
- run: cargo fuzz check --dev --fuzz-dir ./cranelift/isle/fuzz
- run: cargo fuzz check --dev --fuzz-dir ./crates/environ/fuzz --features component-model
@@ -1058,24 +1048,6 @@ jobs:
"OPENSSL_LIB_DIR=$opensslLibDir" | Out-File -FilePath $env:GITHUB_ENV -Append
- run: cargo test -p wasmtime-wasi-tls --all-features
- # Test the `wasmtime-fuzzing` crate. Split out from the main tests because
- # `--all-features` brings in OCaml, which is a pain to get setup for all
- # targets.
- test_fuzzing:
- needs: determine
- if: needs.determine.outputs.run-full
- name: Test wasmtime-fuzzing
- runs-on: 'ubuntu-latest'
- steps:
- - uses: actions/checkout@v7
- with:
- submodules: true
- - uses: ./.github/actions/install-rust
-
- # Run the tests
- - run: |
- cargo test -p wasmtime-fuzzing -p wasm-spec-interpreter
-
# Test debug (DWARF) related functionality.
test_debug_dwarf:
needs: determine
@@ -1477,7 +1449,6 @@ jobs:
- test
- test_capi
- test_debug_dwarf
- - test_fuzzing
- test_nightly
- build
- rustfmt
diff --git a/Cargo.lock b/Cargo.lock
index c0da8b6107..f3be3b871a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1112,12 +1112,6 @@ dependencies = [
"typenum",
]
-[[package]]
-name = "cty"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
-
[[package]]
name = "debugid"
version = "0.8.0"
@@ -2599,35 +2593,6 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "ocaml-boxroot-sys"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5186393bfbee4ce2bc5bbb82beafb77e85c1d0a557e3cfc8c8a0d63d7845fed5"
-dependencies = [
- "cc",
-]
-
-[[package]]
-name = "ocaml-interop"
-version = "0.8.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e01e08412a7e072a90a225d2ae49a2860aeea853ce673bc63891dbf86aed063"
-dependencies = [
- "ocaml-boxroot-sys",
- "ocaml-sys",
- "static_assertions",
-]
-
-[[package]]
-name = "ocaml-sys"
-version = "0.22.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73ec6ca7d41458442627435afb8f4671e83fd642e8a560171d671a1f679aa3cf"
-dependencies = [
- "cty",
-]
-
[[package]]
name = "once_cell"
version = "1.19.0"
@@ -4486,14 +4451,6 @@ dependencies = [
"wat",
]
-[[package]]
-name = "wasm-spec-interpreter"
-version = "0.0.0"
-dependencies = [
- "ocaml-interop",
- "wat",
-]
-
[[package]]
name = "wasm-wave"
version = "0.263.0"
@@ -4905,7 +4862,6 @@ dependencies = [
"wasm-encoder 0.263.0",
"wasm-mutate",
"wasm-smith",
- "wasm-spec-interpreter",
"wasmi",
"wasmparser 0.263.0",
"wasmprinter",
diff --git a/Cargo.toml b/Cargo.toml
index 2fd734b394..b0824707c3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -471,6 +471,7 @@ pin-project-lite = "0.2.14"
sha2 = { version = "0.10.2", default-features = false }
gdbstub = "0.7.10"
gdbstub_arch = "0.3.3"
+v8 = "139.0.0"
# =============================================================================
#
diff --git a/ci/run-tests.py b/ci/run-tests.py
index 69828fbd54..9c70f38a0d 100755
--- a/ci/run-tests.py
+++ b/ci/run-tests.py
@@ -10,12 +10,6 @@
# - wasmtime-wasi-tls: the openssl dependency does not play nice with
# cross compilation. This crate is tested in a separate CI job.
#
-# - wasmtime-fuzzing: enabling all features brings in OCaml which is a pain to
-# configure for all targets, so it has its own CI job.
-#
-# - wasm-spec-interpreter: brings in OCaml which is a pain to configure for all
-# targets, tested as part of the wastime-fuzzing CI job.
-#
# - calculator (under examples/wasip2-plugins): an example that's tested separately.
#
# - cranelift-isle-veri. requires an SMT solver (z3 or cvc5)
@@ -27,8 +21,6 @@ args = ['cargo', 'test', '--workspace', '--all-features']
args.append('--exclude=test-programs')
args.append('--exclude=wasmtime-wasi-nn')
args.append('--exclude=wasmtime-wasi-tls')
-args.append('--exclude=wasmtime-fuzzing')
-args.append('--exclude=wasm-spec-interpreter')
args.append('--exclude=calculator')
args.append('--exclude=cranelift-isle-veri')
args.extend(sys.argv[1:])
diff --git a/crates/fuzzing/Cargo.toml b/crates/fuzzing/Cargo.toml
index 9267f3f525..7cc54edaa4 100644
--- a/crates/fuzzing/Cargo.toml
+++ b/crates/fuzzing/Cargo.toml
@@ -34,7 +34,6 @@ wasmtime-core = { workspace = true, features = ['backtrace', 'serde'] }
wasm-encoder = { workspace = true }
wasm-smith = { workspace = true, features = ['serde'] }
wasm-mutate = { workspace = true }
-wasm-spec-interpreter = { path = "./wasm-spec-interpreter", optional = true }
wasmi = { version = "1.0.8", default-features = false, features = ["std", "simd"] }
futures = { workspace = true }
wasmtime-test-util = { workspace = true, features = ['wast', 'component-fuzz', 'component'] }
@@ -59,12 +58,17 @@ features = [
'stack-switching',
]
-# We rely on precompiled v8 binaries, but rusty-v8 doesn't have a precompiled
-# binary for MinGW which is built on our CI. It does have one for Windows-msvc,
-# though, so we could use that if we wanted. For now though just simplify a bit
-# and don't depend on this on Windows. The same applies on s390x and riscv.
-[target.'cfg(not(any(windows, target_arch = "s390x", target_arch = "riscv64")))'.dependencies]
-v8 = { version = "139.0.0", optional = true }
+# We rely on precompiled v8 binaries, but this crate doesn't have a precompiled
+# version for all platforms. Allow-list certain platforms here that are indeed
+# supported. Keep in-sync with the `build.rs` script for this crate which sets
+# a custom `v8` #[cfg] so testing for the crate is easier in source code
+# itself.
+[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dependencies]
+v8 = { workspace = true, optional = true }
+[target.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.dependencies]
+v8 = { workspace = true, optional = true }
+[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies]
+v8 = { workspace = true, optional = true }
[dev-dependencies]
wat = { workspace = true }
@@ -74,13 +78,6 @@ cranelift-bforest = { workspace = true }
cranelift-bitset = { workspace = true }
tokio = { workspace = true, features = ["rt", "time", "macros", "rt-multi-thread"] }
-# Only enable the `build-libinterpret` feature when fuzzing is enabled, enabling
-# commands like `cargo test --workspace` or similar to not need an ocaml
-# installation and only fuzzers need it by default.
-[target.'cfg(fuzzing)'.dependencies]
-wasm-spec-interpreter = { path = "./wasm-spec-interpreter", optional = true, features = ['build-libinterpret'] }
-
[features]
default = ['v8']
-fuzz-spec-interpreter = ['dep:wasm-spec-interpreter']
v8 = ['dep:v8']
diff --git a/crates/fuzzing/build.rs b/crates/fuzzing/build.rs
index fb56827de9..5d53ed951d 100644
--- a/crates/fuzzing/build.rs
+++ b/crates/fuzzing/build.rs
@@ -44,6 +44,19 @@ fn main() {
// NB: duplicating a workaround in the wasmtime-fiber build script.
custom_cfg("asan", cfg_is("sanitize", "address"));
+
+ let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
+ let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
+
+ // Keep this in sync with the platforms listed in `Cargo.toml` that the
+ // `v8` dependency is enabled for.
+ let v8_supported = match target_os.as_str() {
+ "linux" => target_arch == "x86_64" || target_arch == "aarch64",
+ "macos" => target_arch == "aarch64",
+ _ => false,
+ };
+ let v8 = v8_supported && env::var_os("CARGO_FEATURE_V8").is_some();
+ custom_cfg("v8", v8);
}
fn cfg_is(key: &str, val: &str) -> bool {
diff --git a/crates/fuzzing/src/generators/codegen_settings.rs b/crates/fuzzing/src/generators/codegen_settings.rs
index 2a60e15c98..5a511dd8d6 100644
--- a/crates/fuzzing/src/generators/codegen_settings.rs
+++ b/crates/fuzzing/src/generators/codegen_settings.rs
@@ -146,6 +146,13 @@ impl<'a> Arbitrary<'a> for CodegenSettings {
std: "pacg" => clif: "sign_return_address_all" ratio: 1 in 2,
},
};
+
+ // For hosts not listed in the above just always use the native
+ // codegen settings.
+ if !cfg!(any(target_arch = "x86_64", target_arch = "aarch64")) {
+ return Ok(CodegenSettings::Native);
+ }
+
return Ok(CodegenSettings::Target {
target: target_lexicon::Triple::host().to_string(),
flags,
diff --git a/crates/fuzzing/src/generators/config.rs b/crates/fuzzing/src/generators/config.rs
index db08be6a17..bc96a108ee 100644
--- a/crates/fuzzing/src/generators/config.rs
+++ b/crates/fuzzing/src/generators/config.rs
@@ -389,7 +389,11 @@ impl Config {
};
self.wasmtime.compiler_strategy.configure(&mut cfg);
- self.wasmtime.codegen.configure(&mut cfg);
+ // Host-specific codegen settings (target triple and ISA flags) don't
+ // apply to Pulley, so skip this if that's selected.
+ if *compiler_strategy != CompilerStrategy::CraneliftPulley {
+ self.wasmtime.codegen.configure(&mut cfg);
+ }
cfg.codegen.inlining = self.wasmtime.inlining.map(|i| i.into());
@@ -468,15 +472,6 @@ impl Config {
self.wasmtime.async_config.configure(&mut cfg);
}
- // Fuzzing on macOS with mach ports seems to sometimes bypass the mach
- // port handling thread entirely and go straight to asan's or fuzzing's
- // signal handler. No idea why and for me at least it's just easier to
- // disable mach ports when fuzzing because there's no need to use that
- // over signal handlers.
- if cfg!(target_vendor = "apple") {
- cfg.macos_use_mach_ports(false);
- }
-
return cfg;
}
@@ -684,18 +679,6 @@ impl WasmtimeConfig {
CompilerStrategy::CraneliftNative => {}
CompilerStrategy::Winch => {
- // Winch is not complete on non-x64 targets, so just abandon this test
- // case. We don't want to force Cranelift because we change what module
- // config features are enabled based on the compiler strategy, and we
- // don't want to make the same fuzz input DNA generate different test
- // cases on different targets.
- if cfg!(not(any(target_arch = "x86_64", target_arch = "aarch64"))) {
- log::warn!(
- "want to compile with Winch but host architecture does not support it"
- );
- return Err(arbitrary::Error::IncorrectFormat);
- }
-
// Winch doesn't support the same set of wasm proposal as Cranelift
// at this time, so if winch is selected be sure to disable wasm
// proposals in `Config` to ensure that Winch can compile the
@@ -732,9 +715,22 @@ impl WasmtimeConfig {
CompilerStrategy::CraneliftPulley => {
config.config.threads_enabled = false;
+
+ // Pulley doesn't use signals anyway and this avoids configuring
+ // the engine on platorms which don't support signals anyway, so
+ // alway disable.
+ self.signals_based_traps = false;
}
}
+ // Unconditionally disable s390x signals because in CI they're disabled
+ // in Wasmtime due to possible QEMU emulation bugs (see wasmtime's
+ // `build.rs`). In such a situation if it were enabled here that'd lead
+ // to an error because Wasmtime would claim a lack of support.
+ if cfg!(target_arch = "s390x") {
+ self.signals_based_traps = false;
+ }
+
// If using the pooling allocator, constrain the memory and module configurations
// to the module limits.
if let InstanceAllocationStrategy::Pooling(pooling) = &mut self.strategy {
@@ -988,7 +984,7 @@ impl From<Inlining> for wasmtime::Inlining {
}
}
-#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
/// Compiler to use.
pub enum CompilerStrategy {
/// Cranelift compiler for the native architecture.
@@ -1000,6 +996,17 @@ pub enum CompilerStrategy {
}
impl CompilerStrategy {
+ /// Whether native Cranelift (`CraneliftNative`) can run on this host.
+ pub const CRANELIFT_NATIVE_SUPPORTED: bool = cfg!(any(
+ target_arch = "x86_64",
+ target_arch = "aarch64",
+ target_arch = "riscv64",
+ target_arch = "s390x",
+ ));
+
+ /// Whether Winch can run on this host.
+ pub const WINCH_SUPPORTED: bool = cfg!(any(target_arch = "x86_64", target_arch = "aarch64"));
+
/// Configures `config` to use this compilation strategy
pub fn configure(&self, config: &mut wasmtime_cli_flags::CommonOptions) {
match self {
@@ -1011,7 +1018,13 @@ impl CompilerStrategy {
}
CompilerStrategy::CraneliftPulley => {
config.codegen.compiler = Some(wasmtime::Strategy::Cranelift);
- config.target = Some("pulley64".to_string());
+ if cfg!(target_pointer_width = "32") {
+ config.target = Some("pulley32".to_string());
+ } else if cfg!(target_endian = "big") {
+ config.target = Some("pulley64be".to_string());
+ } else {
+ config.target = Some("pulley64".to_string());
+ }
}
}
}
@@ -1019,13 +1032,28 @@ impl CompilerStrategy {
impl Arbitrary<'_> for CompilerStrategy {
fn arbitrary(u: &mut Unstructured<'_>) -> arbitrary::Result<Self> {
+ // Favor actually using native cranelift, but if it's not actually
+ // supported on this platform then fall back to pulley instead.
+ // Similarly, when winch is selected use that when it's supported,
+ // otherwise fall back to whatever cranelift is.
+ let native = if Self::CRANELIFT_NATIVE_SUPPORTED {
+ Self::CraneliftNative
+ } else {
+ Self::CraneliftPulley
+ };
+ let winch = if Self::WINCH_SUPPORTED {
+ Self::Winch
+ } else {
+ native
+ };
+
// Favor fuzzing native cranelift, but if allowed also enable
// winch/pulley.
- match u.int_in_range(0..=19)? {
- 1 => Ok(Self::CraneliftPulley),
- 2 => Ok(Self::Winch),
- _ => Ok(Self::CraneliftNative),
- }
+ Ok(match u.int_in_range(0..=19)? {
+ 1 => Self::CraneliftPulley,
+ 2 => winch,
+ _ => native,
+ })
}
}
diff --git a/crates/fuzzing/src/generators/memory.rs b/crates/fuzzing/src/generators/memory.rs
index 11c1de0401..fe4eb83df1 100644
--- a/crates/fuzzing/src/generators/memory.rs
+++ b/crates/fuzzing/src/generators/memory.rs
@@ -133,27 +133,32 @@ pub struct MemoryConfig {
impl<'a> Arbitrary<'a> for MemoryConfig {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
+ let max_log2 = if cfg!(target_pointer_width = "32") {
+ 25
+ } else {
+ 63
+ };
Ok(Self {
// Allow up to 8GiB reservations of the virtual address space for
// the initial memory reservation.
- memory_reservation: interesting_virtual_memory_size(u, 33)?,
+ memory_reservation: interesting_virtual_memory_size(u, 33.min(max_log2))?,
// Allow up to 4GiB guard page reservations to be made.
- memory_guard_size: interesting_virtual_memory_size(u, 32)?,
+ memory_guard_size: interesting_virtual_memory_size(u, 32.min(max_log2))?,
// Allow up to 1GiB extra memory to grow into for dynamic memories.
- memory_reservation_for_growth: interesting_virtual_memory_size(u, 30)?,
+ memory_reservation_for_growth: interesting_virtual_memory_size(u, 30.min(max_log2))?,
guard_before_linear_memory: u.arbitrary()?,
cranelift_enable_heap_access_spectre_mitigations: u.arbitrary()?,
memory_init_cow: u.arbitrary()?,
// GC heap tunables, same ranges as corresponding memory tunables.
- gc_heap_reservation: interesting_virtual_memory_size(u, 33)?,
- gc_heap_guard_size: interesting_virtual_memory_size(u, 32)?,
- gc_heap_reservation_for_growth: interesting_virtual_memory_size(u, 30)?,
+ gc_heap_reservation: interesting_virtual_memory_size(u, 33.min(max_log2))?,
+ gc_heap_guard_size: interesting_virtual_memory_size(u, 32.min(max_log2))?,
+ gc_heap_reservation_for_growth: interesting_virtual_memory_size(u, 30.min(max_log2))?,
gc_heap_may_move: u.arbitrary()?,
- gc_heap_initial_size: interesting_virtual_memory_size(u, 22)?,
+ gc_heap_initial_size: interesting_virtual_memory_size(u, 22.min(max_log2))?,
})
}
}
diff --git a/crates/fuzzing/src/oom.rs b/crates/fuzzing/src/oom.rs
index 4dc1fceafa..1febbb9fa4 100644
--- a/crates/fuzzing/src/oom.rs
+++ b/crates/fuzzing/src/oom.rs
@@ -1,7 +1,7 @@
//! Utilities for testing and fuzzing out-of-memory handling.
//!
//! Inspired by SpiderMonkey's `oomTest()` helper:
-//! https://firefox-source-docs.mozilla.org/js/hacking_tips.html#how-to-debug-oomtest-failures
+//! <https://firefox-source-docs.mozilla.org/js/hacking_tips.html#how-to-debug-oomtest-failures>
use backtrace::Backtrace;
use rand::{RngExt, SeedableRng, rngs::SmallRng};
diff --git a/crates/fuzzing/src/oracles.rs b/crates/fuzzing/src/oracles.rs
index 535ca309d5..661cb7c201 100644
--- a/crates/fuzzing/src/oracles.rs
+++ b/crates/fuzzing/src/oracles.rs
@@ -11,8 +11,6 @@
//! panicking.
pub mod component_api;
-#[cfg(feature = "fuzz-spec-interpreter")]
-pub mod diff_spec;
pub mod diff_wasmi;
pub mod diff_wasmtime;
pub mod dummy;
@@ -44,7 +42,7 @@ use std::time::{Duration, Instant};
use wasmtime::*;
use wasmtime_wast::WastContext;
-#[cfg(feature = "v8")]
+#[cfg(v8)]
mod diff_v8;
static CNT: AtomicUsize = AtomicUsize::new(0);
@@ -96,9 +94,15 @@ struct LimitsState {
/// most interesting behavior.
const MAX_MEMORY: usize = 1 << 30;
-/// Allow up to 4G of bytes to be copied (conservatively) which should enable
+/// Maximum number of bytes to be copied (conservatively) which should enable
/// growth up to `MAX_MEMORY` or at least up to a relatively large amount.
-const MAX_MEMORY_MOVED: usize = 4 << 30;
+///
+/// Set to 4G on 64-bit platforms but a bit smaller on 32.
+const MAX_MEMORY_MOVED: usize = if cfg!(target_pointer_width = "32") {
+ 1 << 30
+} else {
+ 4 << 30
+};
impl StoreLimits {
/// Creates the default set of limits for all fuzzing stores.
@@ -637,6 +641,17 @@ pub fn wast_test(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<()> {
return Err(arbitrary::Error::IncorrectFormat);
}
+ // Like integration tests skip all pooling allocator tests on 32-bit
+ // platforms.
+ if cfg!(target_pointer_width = "32")
+ && matches!(
+ fuzz_config.wasmtime.strategy,
+ generators::InstanceAllocationStrategy::Pooling(_)
+ )
+ {
+ return Err(arbitrary::Error::IncorrectFormat);
+ }
+
// Transform `fuzz_config` to be valid for `test` and make sure that this
// test is supposed to pass.
let wast_config = fuzz_config.make_wast_test_compliant(test);
diff --git a/crates/fuzzing/src/oracles/component_api.rs b/crates/fuzzing/src/oracles/component_api.rs
index 24ab9a1be7..21c23bbac0 100644
--- a/crates/fuzzing/src/oracles/component_api.rs
+++ b/crates/fuzzing/src/oracles/component_api.rs
@@ -212,6 +212,16 @@ fn store<T>(input: &mut Unstructured<'_>, val: T) -> arbitrary::Result<Store<T>>
set_min(&mut p.core_instance_size, 64 << 10);
p.memory_protection_keys = Enabled::No;
p.max_memory_size = MEMORY_NEEDED;
+
+ // The default reservation on 32-bit hosts is a bit too small, so ensure
+ // that the default isn't used.
+ if cfg!(target_pointer_width = "32") {
+ config
+ .wasmtime
+ .memory_config
+ .memory_reservation
+ .get_or_insert(MEMORY_NEEDED as u64);
+ }
}
set_opt_min(
&mut config.wasmtime.memory_config.memory_reservation,
diff --git a/crates/fuzzing/src/oracles/diff_spec.rs b/crates/fuzzing/src/oracles/diff_spec.rs
deleted file mode 100644
index 7c0d546c32..0000000000
--- a/crates/fuzzing/src/oracles/diff_spec.rs
+++ /dev/null
@@ -1,160 +0,0 @@
-//! Evaluate an exported Wasm function using the WebAssembly specification
-//! reference interpreter.
-
-use crate::generators::{Config, DiffValue, DiffValueType};
-use crate::oracles::engine::{DiffEngine, DiffInstance};
-use wasm_spec_interpreter::SpecValue;
-use wasmtime::{Error, Result, Trap, format_err};
-
-/// A wrapper for `wasm-spec-interpreter` as a [`DiffEngine`].
-pub struct SpecInterpreter;
-
-impl SpecInterpreter {
- pub(crate) fn new(config: &mut Config) -> Self {
- let config = &mut config.module_config.config;
-
- config.min_memories = config.min_memories.min(1);
- config.max_memories = config.max_memories.min(1);
- config.min_tables = config.min_tables.min(1);
- config.max_tables = config.max_tables.min(1);
-
- config.memory64_enabled = false;
- config.threads_enabled = false;
- config.bulk_memory_enabled = false;
- config.reference_types_enabled = false;
- config.tail_call_enabled = false;
- config.relaxed_simd_enabled = false;
- config.custom_page_sizes_enabled = false;
- config.wide_arithmetic_enabled = false;
- config.extended_const_enabled = false;
- config.exceptions_enabled = false;
-
- Self
- }
-}
-
-impl DiffEngine for SpecInterpreter {
- fn name(&self) -> &'static str {
- "spec"
- }
-
- fn instantiate(&mut self, wasm: &[u8]) -> Result<Box<dyn DiffInstance>> {
- let instance = wasm_spec_interpreter::instantiate(wasm)
- .map_err(|e| format_err!("failed to instantiate in spec interpreter: {e}"))?;
- Ok(Box::new(SpecInstance { instance }))
- }
-
- fn assert_error_match(&self, err: &Error, trap: &Trap) {
- // TODO: implement this for the spec interpreter
- let _ = (trap, err);
- }
-
- fn is_non_deterministic_error(&self, err: &Error) -> bool {
- err.to_string().contains("(Isabelle) call stack exhausted")
- }
-}
-
-struct SpecInstance {
- instance: wasm_spec_interpreter::SpecInstance,
-}
-
-impl DiffInstance for SpecInstance {
- fn name(&self) -> &'static str {
- "spec"
- }
-
- fn evaluate(
- &mut self,
- function_name: &str,
- arguments: &[DiffValue],
- _results: &[DiffValueType],
- ) -> Result<Option<Vec<DiffValue>>> {
- let arguments = arguments.iter().map(SpecValue::from).collect();
- match wasm_spec_interpreter::interpret(&self.instance, function_name, Some(arguments)) {
- Ok(results) => Ok(Some(results.into_iter().map(SpecValue::into).collect())),
- Err(err) => Err(format_err!(err)),
- }
- }
-
- fn get_global(&mut self, name: &str, _ty: DiffValueType) -> Option<DiffValue> {
- use wasm_spec_interpreter::{SpecExport::Global, export};
- if let Ok(Global(g)) = export(&self.instance, name) {
- Some(g.into())
- } else {
- panic!("expected an exported global value at name `{name}`")
- }
- }
-
- fn get_memory(&mut self, name: &str, _shared: bool) -> Option<Vec<u8>> {
- use wasm_spec_interpreter::{SpecExport::Memory, export};
- if let Ok(Memory(m)) = export(&self.instance, name) {
- Some(m)
- } else {
- panic!("expected an exported memory at name `{name}`")
- }
- }
-}
-
-impl From<&DiffValue> for SpecValue {
- fn from(v: &DiffValue) -> Self {
- match *v {
- DiffValue::I32(n) => SpecValue::I32(n),
- DiffValue::I64(n) => SpecValue::I64(n),
- DiffValue::F32(n) => SpecValue::F32(n as i32),
- DiffValue::F64(n) => SpecValue::F64(n as i64),
- DiffValue::V128(n) => SpecValue::V128(n.to_le_bytes().to_vec()),
- DiffValue::FuncRef { .. }
- | DiffValue::ExternRef { .. }
- | DiffValue::AnyRef { .. }
- | DiffValue::ExnRef { .. }
- | DiffValue::ContRef { .. } => {
- unimplemented!()
- }
- }
- }
-}
-
-impl From<SpecValue> for DiffValue {
- fn from(spec: SpecValue) -> DiffValue {
- match spec {
- SpecValue::I32(n) => DiffValue::I32(n),
- SpecValue::I64(n) => DiffValue::I64(n),
- SpecValue::F32(n) => DiffValue::F32(n as u32),
- SpecValue::F64(n) => DiffValue::F64(n as u64),
- SpecValue::V128(n) => {
- assert_eq!(n.len(), 16);
- DiffValue::V128(u128::from_le_bytes(n.as_slice().try_into().unwrap()))
- }
- }
- }
-}
-
-/// Set up the OCaml runtime for triggering its signal handler configuration.
-///
-/// Because both the OCaml runtime and Wasmtime set up signal handlers, we must
-/// carefully decide when to instantiate them; this function allows us to
-/// control when. Wasmtime uses these signal handlers for catching various
-/// WebAssembly failures. On certain OSes (e.g. Linux `x86_64`), the signal
-/// handlers interfere, observable as an uncaught `SIGSEGV`--not even caught by
-/// libFuzzer.
-///
-/// This failure can be mitigated by always running Wasmtime second in
-/// differential fuzzing. In some cases, however, this is not possible because
-/// which engine will execute first is unknown. This function can be explicitly
-/// executed first, e.g., during global initialization, to avoid this issue.
-pub fn setup_ocaml_runtime() {
- wasm_spec_interpreter::setup_ocaml_runtime();
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn smoke() {
- if !wasm_spec_interpreter::support_compiled_in() {
- return;
- }
- crate::oracles::engine::smoke_test_engine(|_, config| Ok(SpecInterpreter::new(config)))
- }
-}
diff --git a/crates/fuzzing/src/oracles/diff_wasmtime.rs b/crates/fuzzing/src/oracles/diff_wasmtime.rs
index 9937b928ee..375c34ae74 100644
--- a/crates/fuzzing/src/oracles/diff_wasmtime.rs
+++ b/crates/fuzzing/src/oracles/diff_wasmtime.rs
@@ -256,6 +256,9 @@ mod tests {
#[test]
fn smoke_cranelift_native() {
+ if !CompilerStrategy::CRANELIFT_NATIVE_SUPPORTED {
+ return;
+ }
crate::oracles::engine::smoke_test_engine(|u, config| {
WasmtimeEngine::new(u, config, CompilerStrategy::CraneliftNative)
})
@@ -270,7 +273,7 @@ mod tests {
#[test]
fn smoke_winch() {
- if !cfg!(target_arch = "x86_64") || !cfg!(target_arch = "aarch64") {
+ if !CompilerStrategy::WINCH_SUPPORTED {
return;
}
crate::oracles::engine::smoke_test_engine(|u, config| {
diff --git a/crates/fuzzing/src/oracles/engine.rs b/crates/fuzzing/src/oracles/engine.rs
index fb2e02514f..0261e92b41 100644
--- a/crates/fuzzing/src/oracles/engine.rs
+++ b/crates/fuzzing/src/oracles/engine.rs
@@ -16,11 +16,10 @@ pub fn build(
config: &mut Config,
) -> arbitrary::Result<Option<Box<dyn DiffEngine>>> {
let engine: Box<dyn DiffEngine> = match name {
- "wasmtime" => Box::new(WasmtimeEngine::new(
- u,
- config,
- CompilerStrategy::CraneliftNative,
- )?),
+ "wasmtime" if CompilerStrategy::CRANELIFT_NATIVE_SUPPORTED => Box::new(
+ WasmtimeEngine::new(u, config, CompilerStrategy::CraneliftNative)?,
+ ),
+ "wasmtime" => return Ok(None),
"pulley" => Box::new(WasmtimeEngine::new(
u,
config,
@@ -28,19 +27,14 @@ pub fn build(
)?),
"wasmi" => Box::new(WasmiEngine::new(config)),
- #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
- "winch" => Box::new(WasmtimeEngine::new(u, config, CompilerStrategy::Winch)?),
- #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
+ "winch" if CompilerStrategy::WINCH_SUPPORTED => {
+ Box::new(WasmtimeEngine::new(u, config, CompilerStrategy::Winch)?)
+ }
"winch" => return Ok(None),
- #[cfg(feature = "fuzz-spec-interpreter")]
- "spec" => Box::new(crate::oracles::diff_spec::SpecInterpreter::new(config)),
- #[cfg(not(feature = "fuzz-spec-interpreter"))]
- "spec" => return Ok(None),
-
- #[cfg(feature = "v8")]
+ #[cfg(v8)]
"v8" => Box::new(crate::oracles::diff_v8::V8Engine::new(config)),
- #[cfg(not(feature = "v8"))]
+ #[cfg(not(v8))]
"v8" => return Ok(None),
_ => panic!("unknown engine {name}"),
@@ -98,8 +92,7 @@ pub trait DiffInstance {
/// Initialize any global state associated with runtimes that may be
/// differentially executed against.
pub fn setup_engine_runtimes() {
- #[cfg(feature = "fuzz-spec-interpreter")]
- crate::oracles::diff_spec::setup_ocaml_runtime();
+ // empty for now
}
/// Build a list of allowed values from the given `defaults` using the
diff --git a/crates/fuzzing/tests/oom/config.rs b/crates/fuzzing/tests/oom/config.rs
index dd54e9e472..c968cd8ed7 100644
--- a/crates/fuzzing/tests/oom/config.rs
+++ b/crates/fuzzing/tests/oom/config.rs
@@ -1,3 +1,8 @@
+// TODO: Config::new always does `std::env::var`, and if that triggers an OOM in
+// the Rust standard library then this test infinite loops. Basically Rust's
+// libstd isn't OOM-safe in that regard. Need to figure out a way around that.
+#![cfg(not(windows))]
+
use wasmtime::{Config, Result};
use wasmtime_fuzzing::oom::OomTest;
diff --git a/crates/fuzzing/wasm-spec-interpreter/Cargo.toml b/crates/fuzzing/wasm-spec-interpreter/Cargo.toml
deleted file mode 100644
index 6018836d11..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/Cargo.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-[package]
-authors = ["The Wasmtime Project Developers"]
-description = "A Rust-to-OCaml wrapper for the WebAssembly specification interpreter"
-name = "wasm-spec-interpreter"
-version = "0.0.0"
-publish = false
-edition.workspace = true
-rust-version.workspace = true
-license = "Apache-2.0 WITH LLVM-exception"
-
-[lints]
-workspace = true
-
-# Until https://gitlab.com/ocaml-rust/ocaml-boxroot/-/issues/1 is resolved and
-# this crate can use the `without-ocamlopt` feature to avoid build failures, it
-# is better to only build the OCaml dependencies when fuzzing (see the
-# `build-libinterpret` feature set by this crate's parent).
-[dependencies]
-ocaml-interop = { version = "0.8", optional = true }
-
-[dev-dependencies]
-wat = { workspace = true }
-
-[features]
-build-libinterpret = ["ocaml-interop"]
diff --git a/crates/fuzzing/wasm-spec-interpreter/README.md b/crates/fuzzing/wasm-spec-interpreter/README.md
deleted file mode 100644
index 2f0c97af13..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/README.md
+++ /dev/null
@@ -1,37 +0,0 @@
-wasm-spec-interpreter
-=====================
-
-This project shows how to use `ocaml-interop` to call into the Wasm spec
-interpreter. There are several steps to making this work:
- - building the OCaml Wasm spec interpreter as a static library
- - building a Rust-to-OCaml FFI bridge using `ocaml-interop` and a custom OCaml
- wrapper
- - linking both things into a Rust crate
-
-### Dependencies
-
-This crate only builds in an environment with:
-- `make` (the Wasm spec interpreter uses a `Makefile`)
-- `ocamlopt`, `ocamlbuild` (available with, e.g., `dnf install ocaml`)
-- Linux tools (e.g. `ar`); currently it is easiest to build the static
- libraries in a single environment but this could be fixed in the future (TODO)
-- `libgmp`, for the OCaml `zarith` package
-- `git` is used by `build.rs` to retrieve the repository containing the Wasm
- spec interpreter; it is safe to completely remove `ocaml/spec` to get a new
- copy
-
-### Build
-
-```
-cargo build --features build-libinterpret
-```
-
-Use `FFI_LIB_DIR=path/to/lib/...` to specify a different location for the static
-library (this is mainly for debugging). If the `build-libinterpret` feature is
-not provided, this crate will build successfully but fail at runtime.
-
-### Test
-
-```
-cargo test --features build-libinterpret
-```
diff --git a/crates/fuzzing/wasm-spec-interpreter/build.rs b/crates/fuzzing/wasm-spec-interpreter/build.rs
deleted file mode 100644
index ecae47fad2..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/build.rs
+++ /dev/null
@@ -1,97 +0,0 @@
-/// Build the OCaml code and statically link it into the Rust library; see the
-/// [ocaml-interop
-/// example](https://github.com/tezedge/ocaml-interop/blob/master/testing/rust-caller/build.rs)
-/// for more details. After playing with this a bit, I discovered that the best
-/// approach to avoid missing symbols was to imitate `dune`: I observed `rm -rf
-/// _build && dune build ./ocaml/interpret.exe.o --display=verbose` and used
-/// that as a pattern, now encoded in `ocaml/Makefile` for easier debugging.
-use std::{env, path::PathBuf, process::Command};
-
-const LIB_NAME: &'static str = "interpret";
-const OCAML_DIR: &'static str = "ocaml";
-const SPEC_DIR: &'static str = "ocaml/spec";
-const SPEC_REPOSITORY: &'static str = "https://github.com/conrad-watt/spec";
-const SPEC_REPOSITORY_BRANCH: &'static str = "wasmtime_fuzzing";
-const SPEC_REPOSITORY_REV: &'static str = "c6bab4461e10229e557aae2e1027cadfce0161ce";
-
-fn main() {
- println!("cargo:rustc-check-cfg=cfg(feature, values(\"has-libinterpret\"))");
- println!("cargo:rustc-check-cfg=cfg(fuzzing)");
- if cfg!(feature = "build-libinterpret") {
- build();
- }
-}
-
-fn build() {
- let out_dir = &env::var("OUT_DIR").unwrap();
-
- // Re-run if changed.
- println!("cargo:rerun-if-changed={OCAML_DIR}/{LIB_NAME}.ml");
- println!("cargo:rerun-if-changed={OCAML_DIR}/Makefile");
-
- if let Some(other_dir) = env::var_os("FFI_LIB_DIR") {
- // Link with a library provided in the `FFI_LIB_DIR`.
- println!("cargo:rustc-link-search={}", other_dir.to_str().unwrap());
- println!("cargo:rustc-link-lib=static={LIB_NAME}");
- } else {
- // Ensure the spec repository is present.
- if is_spec_repository_empty(SPEC_DIR) {
- retrieve_spec_repository(SPEC_DIR)
- }
-
- // Build the library to link to.
- build_lib(out_dir, OCAML_DIR);
- println!("cargo:rustc-link-search={out_dir}");
- println!("cargo:rustc-link-lib=static={LIB_NAME}");
- }
-
- // Enabling this feature alerts the compiler to use the `with_library`
- // module.
- println!("cargo:rustc-cfg=feature=\"has-libinterpret\"");
-}
-
-// Build the OCaml library into Cargo's `out` directory.
-fn build_lib(out_dir: &str, ocaml_dir: &str) {
- let status = Command::new("make")
- .arg(format!("BUILD_DIR={out_dir}"))
- .current_dir(ocaml_dir)
- .status()
- .expect("Failed to execute 'make' command to build OCaml library");
-
- assert!(
- status.success(),
- "Failed to build the OCaml library using 'make'."
- )
-}
-
-// Check if the spec repository directory contains any files.
-fn is_spec_repository_empty(destination: &str) -> bool {
- PathBuf::from(destination)
- .read_dir()
- .map(|mut i| i.next().is_none())
- .unwrap_or(true)
-}
-
-// Clone the spec repository into `destination`. This exists due to the large
-// size of the dependencies (e.g. KaTeX) that are pulled if this were cloned
-// recursively as a submodule.
-fn retrieve_spec_repository(destination: &str) {
- let status = Command::new("git")
- .arg("clone")
- .arg(SPEC_REPOSITORY)
- .arg("-b")
- .arg(SPEC_REPOSITORY_BRANCH)
- .arg(destination)
- .status()
- .expect("Failed to execute 'git' command to clone spec repository.");
- assert!(status.success(), "Failed to retrieve the spec repository.");
-
- let status = Command::new("git")
- .arg("reset")
- .arg("--hard")
- .arg(SPEC_REPOSITORY_REV)
- .current_dir(destination)
- .status()
- .expect("Failed to execute 'git' command to clone spec repository.");
- assert!(status.success(), "Failed to reset to revision.");
-}
diff --git a/crates/fuzzing/wasm-spec-interpreter/ocaml/.gitignore b/crates/fuzzing/wasm-spec-interpreter/ocaml/.gitignore
deleted file mode 100644
index 1e82b679cf..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/ocaml/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-_build
-spec
diff --git a/crates/fuzzing/wasm-spec-interpreter/ocaml/Makefile b/crates/fuzzing/wasm-spec-interpreter/ocaml/Makefile
deleted file mode 100644
index 3637b75ae1..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/ocaml/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-# Build a library allowing FFI access to the Wasm spec interpreter.
-
-OCAML_FLAGS := -g -keep-locs -runtime-variant _pic
-# By default, we build in a sub-directory but we can override this with `make
-# BUILD_DIR=...`.
-BUILD_DIR := _build
-# Currently the WebAssembly spec interpreter is buried in a Git submodule as is
-# its build directory, `_build`. Cargo may not like that files are changing
-# outside of `target` (TODO).
-SPEC_DIR := spec/interpreter
-SPEC_BUILD_DIR := $(SPEC_DIR)/_build
-SPEC_LIB := $(SPEC_BUILD_DIR)/wasm.cmxa
-
-# A space-separated list of paths that the linker will use to search for libgmp.
-# Override with `make LIBGMP_PATHS=...`.
-LIBGMP_PATHS ?= /usr/lib /usr/lib/x86_64-linux-gnu /lib64
-
-PKGS = zarith
-
-# Build and package the static library, `libinterpret.a`.
-$(BUILD_DIR)/libinterpret.a: $(BUILD_DIR)/interpret.lib.o
- ar qs $@ $^
-$(BUILD_DIR)/interpret.lib.o: $(SPEC_LIB) $(BUILD_DIR)/interpret.cmx
- ocamlfind ocamlopt $(OCAML_FLAGS) -I $(SPEC_BUILD_DIR) -o $@ -output-complete-obj $^ -linkpkg $(PKGS:%=-package %) -cclib "$(LIBGMP_PATHS:%=-L%)"
-$(BUILD_DIR)/interpret.cmx: interpret.ml $(SPEC_BUILD_DIR) $(BUILD_DIR)
- ocamlfind ocamlopt $(OCAML_FLAGS) -I $(SPEC_BUILD_DIR) -o $@ -c -impl $< -linkpkg $(PKGS:%=-package %)
-$(BUILD_DIR):
- mkdir -p $@
-
-
-# We also need to be able to build the spec's `wasm.cmxa`.
-$(SPEC_LIB):
- make -C $(SPEC_DIR) libopt
-
-
-clean:
- rm -rf $(BUILD_DIR)
- make -C $(SPEC_DIR) clean
diff --git a/crates/fuzzing/wasm-spec-interpreter/ocaml/README.md b/crates/fuzzing/wasm-spec-interpreter/ocaml/README.md
deleted file mode 100644
index fa1e0e83df..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/ocaml/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-This directory contains the necessary parts for building a library with FFI
-access to the Wasm spec interpreter. Its major parts:
- - `spec`: the Wasm spec code as a Git submodule (you may need to retrieve it:
- `git clone -b wasmtime_fuzzing https://github.com/conrad-watt/spec`).
- - `interpret.ml`: a shim layer for calling the Wasm spec code and exposing it
- for FFI access
- - `Makefile`: the steps for gluing these pieces together into a static library
-
-Note: the `Makefile` must be configured with the path to `libgmp.a`; see
-`LIBGMP_PATHS` in the `Makefile` (Ubuntu: `libgmp-dev`, Fedora: `gmp-static`).
diff --git a/crates/fuzzing/wasm-spec-interpreter/ocaml/interpret.ml b/crates/fuzzing/wasm-spec-interpreter/ocaml/interpret.ml
deleted file mode 100644
index 883bd5ec06..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/ocaml/interpret.ml
+++ /dev/null
@@ -1,140 +0,0 @@
-(* This module exposes an [interpret] function to Rust. It wraps several
-different calls from the WebAssembly specification interpreter in a way that we
-can access across the FFI boundary. To understand this better, see:
- - the OCaml manual documentation re: calling OCaml from C,
- https://ocaml.org/manual/intfc.html#s%3Ac-advexample
- - the [ocaml-interop] example,
- https://github.com/tezedge/ocaml-interop/blob/master/testing/rust-caller/ocaml/callable.ml
-*)
-
-(** Enumerate the types of values we pass across the FFI boundary. This must
-match `Value` in `src/lib.rs` *)
-type ffi_value =
- | I32 of int32
- | I64 of int64
- | F32 of int32
- | F64 of int64
- | V128 of Bytes.t
-
-(** Enumerate the kinds of exported values the interpreter can retrieve. *)
-type ffi_export_value =
- | Global of ffi_value
- | Memory of Bytes.t
-
-(* Here we access the WebAssembly specification interpreter; this must be linked
-in. *)
-open Wasm
-open Wasm.WasmRef_Isa_m.WasmRef_Isa
-
-type spec_instance = (unit module_export_ext list * ((unit s_m_ext) ref))
-
-(** Helper for converting the FFI values to their spec interpreter type. *)
-let convert_to_wasm (v: ffi_value) : v = match v with
-| I32 n -> V_num (ConstInt32 (I32_impl_abs n))
-| I64 n -> V_num (ConstInt64 (I64_impl_abs n))
-| F32 n -> V_num (ConstFloat32 (F32.of_bits n))
-| F64 n -> V_num (ConstFloat64 (F64.of_bits n))
-| V128 n -> V_vec (ConstVec128 (V128.of_bits (Bytes.to_string n)))
-
-(** Helper for converting the spec interpreter values to their FFI type. *)
-let convert_from_wasm (v: v) : ffi_value = match v with
-| V_num ((ConstInt32 (I32_impl_abs n))) -> I32 n
-| V_num ((ConstInt64 (I64_impl_abs n))) -> I64 n
-| V_num ((ConstFloat32 n)) -> F32 (F32.to_bits n)
-| V_num ((ConstFloat64 n)) -> F64 (F64.to_bits n)
-| V_vec ((ConstVec128 n)) -> V128 (Bytes.of_string (V128.to_bits n))
-
-(** Parse the given WebAssembly module binary into an Ast.module_. At some point
-in the future this should also be able to parse the textual form (TODO). *)
-let parse bytes =
- (* Optionally, use Bytes.unsafe_to_string here to avoid the copy *)
- let bytes_as_str = Bytes.to_string bytes in
- (Decode.decode "default" bytes_as_str)
-
-(** Construct an instance from a sequence of WebAssembly bytes. This clears the
-previous contents of the global store *)
-let instantiate_exn module_bytes : spec_instance =
- let s = (make_empty_store_m ()) in
- let module_ = parse module_bytes in
- let m_isa = Ast_convert.convert_module (module_.it) in
- (match interp_instantiate_init_m s m_isa [] () with
- | (s', (RI_res_m(inst,v_exps,_))) -> (v_exps, ref s')
- | (s', (RI_trap_m str)) -> raise (Eval.Trap (Source.no_region, "(Isabelle) trap: " ^ str))
- | (s', (RI_crash_m (Error_exhaustion str))) -> raise (Eval.Exhaustion (Source.no_region, "(Isabelle) call stack exhausted"))
- | (s', (RI_crash_m (Error_invalid str))) -> raise (Eval.Crash (Source.no_region, "(Isabelle) error: " ^ str))
- | (s', (RI_crash_m (Error_invariant str))) -> raise (Eval.Crash (Source.no_region, "(Isabelle) error: " ^ str))
- )
-
-let instantiate module_bytes =
- try Ok(instantiate_exn module_bytes) with
- | _ as e -> Error(Printexc.to_string e)
-
-(** Retrieve the value of an export by name from a WebAssembly instance. *)
-let export_exn (inst_s : spec_instance) (name : string) : ffi_export_value =
- let (inst, s_ref) = inst_s in
- match (e_desc (List.find (fun exp -> String.equal (e_name exp) name) inst)) with
- Ext_func _ -> raise Not_found
- | Ext_tab _ -> raise Not_found
- | Ext_mem i -> Memory (fst (Array.get (mems (!s_ref)) (Z.to_int (integer_of_nat i))))
- | Ext_glob i -> Global (convert_from_wasm (g_val (Array.get (globs (!s_ref)) (Z.to_int (integer_of_nat i)))))
-
-let export inst name =
- try Ok(export_exn inst name) with
- | _ as e -> Error(Printexc.to_string e)
-
-(** Interpret the first exported function and return the result. Use provided
-parameters if they exist, otherwise use default (zeroed) values. *)
-let interpret_legacy_exn module_bytes opt_params =
- let opt_params_ = Option.map (List.rev_map convert_to_wasm) opt_params in
- let module_ = parse module_bytes in
- let m_isa = Ast_convert.convert_module (module_.it) in
- let fuel = Z.of_string "4611686018427387904" in
- let max_call_depth = Z.of_string "300" in
- (match run_fuzz (nat_of_integer fuel) (nat_of_integer max_call_depth) (make_empty_store_m ()) m_isa [] opt_params_ () with
- | (s', RValue vs_isa') -> List.rev_map convert_from_wasm vs_isa'
- | (s', RTrap str) -> raise (Eval.Trap (Source.no_region, "(Isabelle) trap: " ^ str))
- | (s', (RCrash (Error_exhaustion str))) -> raise (Eval.Exhaustion (Source.no_region, "(Isabelle) call stack exhausted"))
- | (s', (RCrash (Error_invalid str))) -> raise (Eval.Crash (Source.no_region, "(Isabelle) error: " ^ str))
- | (s', (RCrash (Error_invariant str))) -> raise (Eval.Crash (Source.no_region, "(Isabelle) error: " ^ str))
- )
-
-let interpret_legacy module_bytes opt_params =
- try Ok(interpret_legacy_exn module_bytes opt_params) with
- | _ as e -> Error(Printexc.to_string e)
-
-(* process an optional list of params, generating default params if necessary *)
-(* TODO: this should be done in the Isabelle model *)
-let get_param_vs s_ref (vs_opt :(ffi_value list) option) i =
- (match vs_opt with
- | None -> (match cl_m_type ((array_nth heap_cl_m (funcs !s_ref) i) ()) with Tf (t1, _) -> map bitzero t1)
- | Some vs -> List.map convert_to_wasm vs)
-
-(** Interpret the function exported at name. Use provided
-parameters if they exist, otherwise use default (zeroed) values. *)
-let interpret_exn (inst_s : spec_instance) (name : string) opt_params =
- (let fuel = Z.of_string "4611686018427387904" in
- let max_call_depth = Z.of_string "300" in
- let (inst, s_ref) = inst_s in
- match (e_desc (List.find (fun exp -> String.equal (e_name exp) name) inst)) with
- | Ext_func i ->
- (let params = get_param_vs s_ref opt_params i in
- let (s', res) = run_invoke_v_m (nat_of_integer fuel) (nat_of_integer max_call_depth) ((!s_ref), (params, i)) () in
- s_ref := s';
- (match res with
- | RValue vs_isa' -> List.rev_map convert_from_wasm vs_isa'
- | RTrap str -> raise (Eval.Trap (Source.no_region, "(Isabelle) trap: " ^ str))
- | (RCrash (Error_exhaustion str)) -> raise (Eval.Exhaustion (Source.no_region, "(Isabelle) call stack exhausted"))
- | (RCrash (Error_invalid str)) -> raise (Eval.Crash (Source.no_region, "(Isabelle) error: " ^ str))
- | (RCrash (Error_invariant str)) -> raise (Eval.Crash (Source.no_region, "(Isabelle) error: " ^ str))
- ))
- | _ -> raise Not_found)
-
-let interpret inst name opt_params =
- try Ok(interpret_exn inst name opt_params) with
- | _ as e -> Error(Printexc.to_string e)
-
-let () =
- Callback.register "instantiate" instantiate;
- Callback.register "interpret_legacy" interpret_legacy;
- Callback.register "interpret" interpret;
- Callback.register "export" export;
diff --git a/crates/fuzzing/wasm-spec-interpreter/src/lib.rs b/crates/fuzzing/wasm-spec-interpreter/src/lib.rs
deleted file mode 100644
index caf9441458..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/src/lib.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-//! This library provides a way to interpret Wasm functions in the official Wasm
-//! specification interpreter, written in OCaml, from Rust.
-//!
-//! In order to not break Wasmtime's build, this library will always compile. It
-//! does depend on certain tools (see `README.md`) that may or may not be
-//! available in the environment:
-//! - when the tools are available, we build and link to an OCaml static
-//! library (see `with_library` module)
-//! - when the tools are not available, this library will panic at runtime (see
-//! `without_library` module).
-
-/// Enumerate the kinds of Wasm values the OCaml interpreter can handle.
-#[derive(Clone, Debug, PartialEq)]
-pub enum SpecValue {
- I32(i32),
- I64(i64),
- F32(i32),
- F64(i64),
- V128(Vec<u8>),
-}
-
-/// Represents a WebAssembly export from the OCaml interpreter side.
-pub enum SpecExport {
- Global(SpecValue),
- Memory(Vec<u8>),
-}
-
-/// Represents a WebAssembly instance from the OCaml interpreter side.
-pub struct SpecInstance {
- #[cfg(feature = "has-libinterpret")]
- repr: ocaml_interop::BoxRoot<SpecInstance>,
-}
-
-#[cfg(feature = "has-libinterpret")]
-mod with_library;
-#[cfg(feature = "has-libinterpret")]
-pub use with_library::*;
-
-#[cfg(not(feature = "has-libinterpret"))]
-mod without_library;
-#[cfg(not(feature = "has-libinterpret"))]
-pub use without_library::*;
-
-// If the user is fuzzing`, we expect the OCaml library to have been built.
-#[cfg(all(fuzzing, not(feature = "has-libinterpret")))]
-compile_error!("The OCaml library was not built.");
-
-/// Check if the OCaml spec interpreter bindings will work.
-pub fn support_compiled_in() -> bool {
- cfg!(feature = "has-libinterpret")
-}
diff --git a/crates/fuzzing/wasm-spec-interpreter/src/with_library.rs b/crates/fuzzing/wasm-spec-interpreter/src/with_library.rs
deleted file mode 100644
index e427379d74..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/src/with_library.rs
+++ /dev/null
@@ -1,353 +0,0 @@
-//! Interpret WebAssembly modules using the OCaml spec interpreter.
-//!
-//! ```
-//! # use wasm_spec_interpreter::{SpecValue, interpret, instantiate};
-//! let module = wat::parse_file("tests/add.wat").unwrap();
-//! let instance = instantiate(&module).unwrap();
-//! let parameters = vec![SpecValue::I32(42), SpecValue::I32(1)];
-//! let results = interpret(&instance, "add", Some(parameters)).unwrap();
-//! assert_eq!(results, &[SpecValue::I32(43)]);
-//! ```
-//!
-//! ### Warning
-//!
-//! The OCaml runtime is [not re-entrant]. The code below must ensure that only
-//! one Rust thread is executing at a time (using the `INTERPRET` lock) or we
-//! may observe `SIGSEGV` failures, e.g., while running `cargo test`.
-//!
-//! [not re-entrant]:
-//! https://ocaml.org/manual/intfc.html#ss:parallel-execution-long-running-c-code
-//!
-//! ### Warning
-//!
-//! This module uses an unsafe approach (`OCamlRuntime::init_persistent()` +
-//! `OCamlRuntime::recover_handle()`) to initializing the `OCamlRuntime` based
-//! on some [discussion] with `ocaml-interop` crate authors. This approach was
-//! their recommendation to resolve seeing errors like `boxroot is not setup`
-//! followed by a `SIGSEGV`; this is similar to the testing approach [they use].
-//! Use this approach with care and note that it is only as safe as the OCaml
-//! code running underneath.
-//!
-//! [discussion]: https://github.com/tezedge/ocaml-interop/issues/35
-//! [they use]:
-//! https://github.com/tezedge/ocaml-interop/blob/master/testing/rust-caller/src/lib.rs
-
-use crate::{SpecExport, SpecInstance, SpecValue};
-use ocaml_interop::{BoxRoot, OCamlRuntime, ToOCaml};
-use std::sync::Mutex;
-
-static INTERPRET: Mutex<()> = Mutex::new(());
-
-/// Instantiate the WebAssembly module in the spec interpreter.
-pub fn instantiate(module: &[u8]) -> Result<SpecInstance, String> {
- let _lock = INTERPRET.lock().unwrap();
- OCamlRuntime::init_persistent();
- let ocaml_runtime = unsafe { OCamlRuntime::recover_handle() };
-
- let module = module.to_boxroot(ocaml_runtime);
- let instance = ocaml_bindings::instantiate(ocaml_runtime, &module);
- instance.to_rust(ocaml_runtime)
-}
-
-/// Interpret the exported function `name` with the given `parameters`.
-pub fn interpret(
- instance: &SpecInstance,
- name: &str,
- parameters: Option<Vec<SpecValue>>,
-) -> Result<Vec<SpecValue>, String> {
- let _lock = INTERPRET.lock().unwrap();
- OCamlRuntime::init_persistent();
- let ocaml_runtime = unsafe { OCamlRuntime::recover_handle() };
-
- // Prepare the box-rooted parameters.
- let instance = instance.to_boxroot(ocaml_runtime);
- let name = name.to_string().to_boxroot(ocaml_runtime);
- let parameters = parameters.to_boxroot(ocaml_runtime);
-
- // Interpret the function.
- let results = ocaml_bindings::interpret(ocaml_runtime, &instance, &name, &parameters);
- results.to_rust(&ocaml_runtime)
-}
-
-/// Interpret the first function in the passed WebAssembly module (in Wasm form,
-/// currently, not WAT), optionally with the given parameters. If no parameters
-/// are provided, the function is invoked with zeroed parameters.
-pub fn interpret_legacy(
- module: &[u8],
- opt_parameters: Option<Vec<SpecValue>>,
-) -> Result<Vec<SpecValue>, String> {
- let _lock = INTERPRET.lock().unwrap();
- OCamlRuntime::init_persistent();
- let ocaml_runtime = unsafe { OCamlRuntime::recover_handle() };
-
- // Parse and execute, returning results converted to Rust.
- let module = module.to_boxroot(ocaml_runtime);
- let opt_parameters = opt_parameters.to_boxroot(ocaml_runtime);
- let results = ocaml_bindings::interpret_legacy(ocaml_runtime, &module, &opt_parameters);
- results.to_rust(ocaml_runtime)
-}
-
-/// Retrieve the export given by `name`.
-pub fn export(instance: &SpecInstance, name: &str) -> Result<SpecExport, String> {
- let _lock = INTERPRET.lock().unwrap();
- OCamlRuntime::init_persistent();
- let ocaml_runtime = unsafe { OCamlRuntime::recover_handle() };
-
- // Prepare the box-rooted parameters.
- let instance = instance.to_boxroot(ocaml_runtime);
- let name = name.to_string().to_boxroot(ocaml_runtime);
-
- // Export the value.
- let results = ocaml_bindings::export(ocaml_runtime, &instance, &name);
- results.to_rust(&ocaml_runtime)
-}
-
-// Here we declare which functions we will use from the OCaml library. See
-// https://docs.rs/ocaml-interop/0.8.4/ocaml_interop/index.html#example.
-mod ocaml_bindings {
- use super::*;
- use ocaml_interop::{
- FromOCaml, OCaml, OCamlBytes, OCamlInt32, OCamlInt64, OCamlList, impl_conv_ocaml_variant,
- ocaml,
- };
-
- // Using this macro converts the enum both ways: Rust to OCaml and OCaml to
- // Rust. See
- // https://docs.rs/ocaml-interop/0.8.4/ocaml_interop/macro.impl_conv_ocaml_variant.html.
- impl_conv_ocaml_variant! {
- SpecValue {
- SpecValue::I32(i: OCamlInt32),
- SpecValue::I64(i: OCamlInt64),
- SpecValue::F32(i: OCamlInt32),
- SpecValue::F64(i: OCamlInt64),
- SpecValue::V128(i: OCamlBytes),
- }
- }
-
- // We need to also convert the `SpecExport` enum.
- impl_conv_ocaml_variant! {
- SpecExport {
- SpecExport::Global(i: SpecValue),
- SpecExport::Memory(i: OCamlBytes),
- }
- }
-
- // We manually show `SpecInstance` how to convert itself to and from OCaml.
- unsafe impl FromOCaml<SpecInstance> for SpecInstance {
- fn from_ocaml(v: OCaml<SpecInstance>) -> Self {
- Self {
- repr: BoxRoot::new(v),
- }
- }
- }
- unsafe impl ToOCaml<SpecInstance> for SpecInstance {
- fn to_ocaml<'a>(&self, cr: &'a mut OCamlRuntime) -> OCaml<'a, SpecInstance> {
- BoxRoot::get(&self.repr, cr)
- }
- }
-
- // These functions must be exposed from OCaml with:
- // `Callback.register "interpret" interpret`
- //
- // In Rust, these functions look like:
- // `pub fn interpret(_: &mut OCamlRuntime, ...: OCamlRef<...>) -> BoxRoot<...>;`
- //
- // The `ocaml!` macro does not understand documentation, so the
- // documentation is included here:
- // - `instantiate`: clear the global store and instantiate a new WebAssembly
- // module from bytes
- // - `interpret`: given an instance, call the function exported at `name`
- // - `interpret_legacy`: starting from bytes, instantiate and execute the
- // first exported function
- // - `export`: given an instance, get the value of the export at `name`
- ocaml! {
- pub fn instantiate(module: OCamlBytes) -> Result<SpecInstance, String>;
- pub fn interpret(instance: SpecInstance, name: String, params: Option<OCamlList<SpecValue>>) -> Result<OCamlList<SpecValue>, String>;
- pub fn interpret_legacy(module: OCamlBytes, params: Option<OCamlList<SpecValue>>) -> Result<OCamlList<SpecValue>, String>;
- pub fn export(instance: SpecInstance, name: String) -> Result<SpecExport, String>;
- }
-}
-
-/// Initialize a persistent OCaml runtime.
-///
-/// When used for fuzzing differentially with engines that also use signal
-/// handlers, this function provides a way to explicitly set up the OCaml
-/// runtime and configure its signal handlers.
-pub fn setup_ocaml_runtime() {
- let _lock = INTERPRET.lock().unwrap();
- OCamlRuntime::init_persistent();
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn invalid_function_name() {
- let module = wat::parse_file("tests/add.wat").unwrap();
- let instance = instantiate(&module).unwrap();
- let results = interpret(
- &instance,
- "not-the-right-name",
- Some(vec![SpecValue::I32(0), SpecValue::I32(0)]),
- );
- assert_eq!(results, Err("Not_found".to_string()));
- }
-
- #[test]
- fn multiple_invocation() {
- let module = wat::parse_file("tests/add.wat").unwrap();
- let instance = instantiate(&module).unwrap();
-
- let results1 = interpret(
- &instance,
- "add",
- Some(vec![SpecValue::I32(42), SpecValue::I32(1)]),
- )
- .unwrap();
- let results2 = interpret(
- &instance,
- "add",
- Some(vec![SpecValue::I32(1), SpecValue::I32(42)]),
- )
- .unwrap();
- assert_eq!(results1, results2);
-
- let results3 = interpret(
- &instance,
- "add",
- Some(vec![SpecValue::I32(20), SpecValue::I32(23)]),
- )
- .unwrap();
- assert_eq!(results2, results3);
- }
-
- #[test]
- fn multiple_invocation_legacy() {
- let module = wat::parse_file("tests/add.wat").unwrap();
-
- let results1 =
- interpret_legacy(&module, Some(vec![SpecValue::I32(42), SpecValue::I32(1)])).unwrap();
- let results2 =
- interpret_legacy(&module, Some(vec![SpecValue::I32(1), SpecValue::I32(42)])).unwrap();
- assert_eq!(results1, results2);
-
- let results3 =
- interpret_legacy(&module, Some(vec![SpecValue::I32(20), SpecValue::I32(23)])).unwrap();
- assert_eq!(results2, results3);
- }
-
- #[test]
- fn oob() {
- let module = wat::parse_file("tests/oob.wat").unwrap();
- let instance = instantiate(&module).unwrap();
- let results = interpret(&instance, "oob", None);
- assert_eq!(
- results,
- Err("Error(_, \"(Isabelle) trap: load\")".to_string())
- );
- }
-
- #[test]
- fn oob_legacy() {
- let module = wat::parse_file("tests/oob.wat").unwrap();
- let results = interpret_legacy(&module, None);
- assert_eq!(
- results,
- Err("Error(_, \"(Isabelle) trap: load\")".to_string())
- );
- }
-
- #[test]
- fn simd_not() {
- let module = wat::parse_file("tests/simd_not.wat").unwrap();
- let instance = instantiate(&module).unwrap();
-
- let parameters = Some(vec![SpecValue::V128(vec![
- 0, 255, 0, 0, 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0,
- ])]);
- let results = interpret(&instance, "simd_not", parameters).unwrap();
-
- assert_eq!(
- results,
- vec![SpecValue::V128(vec![
- 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255
- ])]
- );
- }
-
- #[test]
- fn simd_not_legacy() {
- let module = wat::parse_file("tests/simd_not.wat").unwrap();
-
- let parameters = Some(vec![SpecValue::V128(vec![
- 0, 255, 0, 0, 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0,
- ])]);
- let results = interpret_legacy(&module, parameters).unwrap();
-
- assert_eq!(
- results,
- vec![SpecValue::V128(vec![
- 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255
- ])]
- );
- }
-
- // See issue https://github.com/bytecodealliance/wasmtime/issues/4671.
- #[test]
- fn order_of_params() {
- let module = wat::parse_file("tests/shr_s.wat").unwrap();
- let instance = instantiate(&module).unwrap();
-
- let parameters = Some(vec![
- SpecValue::I32(1795123818),
- SpecValue::I32(-2147483648),
- ]);
- let results = interpret(&instance, "test", parameters).unwrap();
-
- assert_eq!(results, vec![SpecValue::I32(1795123818)]);
- }
-
- // See issue https://github.com/bytecodealliance/wasmtime/issues/4671.
- #[test]
- fn order_of_params_legacy() {
- let module = wat::parse_file("tests/shr_s.wat").unwrap();
-
- let parameters = Some(vec![
- SpecValue::I32(1795123818),
- SpecValue::I32(-2147483648),
- ]);
- let results = interpret_legacy(&module, parameters).unwrap();
-
- assert_eq!(results, vec![SpecValue::I32(1795123818)]);
- }
-
- #[test]
- fn load_store_and_export() {
- let module = wat::parse_file("tests/memory.wat").unwrap();
- let instance = instantiate(&module).unwrap();
-
- // Store 42 at offset 4.
- let _ = interpret(
- &instance,
- "store_i32",
- Some(vec![SpecValue::I32(4), SpecValue::I32(42)]),
- );
-
- // Load an i32 from offset 4.
- let loaded = interpret(&instance, "load_i32", Some(vec![SpecValue::I32(4)]));
-
- // Check stored value was retrieved.
- assert_eq!(loaded.unwrap(), vec![SpecValue::I32(42)]);
-
- // Retrieve the memory exported with name "mem" and check that the
- // 32-bit value at byte offset 4 of memory is 42.
- let export = export(&instance, "mem");
- match export.unwrap() {
- SpecExport::Global(_) => panic!("incorrect export"),
- SpecExport::Memory(m) => {
- assert_eq!(&m[0..10], [0, 0, 0, 0, 42, 0, 0, 0, 0, 0]);
- }
- }
- }
-}
diff --git a/crates/fuzzing/wasm-spec-interpreter/src/without_library.rs b/crates/fuzzing/wasm-spec-interpreter/src/without_library.rs
deleted file mode 100644
index 8b714eb775..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/src/without_library.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-//! Panic when interpreting WebAssembly modules; see the rationale for this in
-//! `lib.rs`.
-//!
-//! ```should_panic
-//! # use wasm_spec_interpreter::instantiate;
-//! let _ = instantiate(&[]);
-//! ```
-
-use crate::{SpecExport, SpecInstance, SpecValue};
-
-pub fn instantiate(_module: &[u8]) -> Result<SpecInstance, String> {
- fail_at_runtime()
-}
-
-pub fn interpret(
- _instance: &SpecInstance,
- _name: &str,
- _parameters: Option<Vec<SpecValue>>,
-) -> Result<Vec<SpecValue>, String> {
- fail_at_runtime()
-}
-
-pub fn interpret_legacy(
- _module: &[u8],
- _parameters: Option<Vec<SpecValue>>,
-) -> Result<Vec<SpecValue>, String> {
- fail_at_runtime()
-}
-
-pub fn export(_instance: &SpecInstance, _name: &str) -> Result<SpecExport, String> {
- fail_at_runtime()
-}
-
-fn fail_at_runtime() -> ! {
- panic!(
- "wasm-spec-interpreter was built without its Rust-to-OCaml shim \
- library; re-compile with the dependencies listed in its README.md."
- );
-}
-
-pub fn setup_ocaml_runtime() {}
diff --git a/crates/fuzzing/wasm-spec-interpreter/tests/add.wat b/crates/fuzzing/wasm-spec-interpreter/tests/add.wat
deleted file mode 100644
index e664c99b4e..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/tests/add.wat
+++ /dev/null
@@ -1,5 +0,0 @@
-(module
- (func (export "add") (param $a i32) (param $b i32) (result i32)
- local.get $a
- local.get $b
- i32.add))
diff --git a/crates/fuzzing/wasm-spec-interpreter/tests/memory.wat b/crates/fuzzing/wasm-spec-interpreter/tests/memory.wat
deleted file mode 100644
index d0319aecbe..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/tests/memory.wat
+++ /dev/null
@@ -1,12 +0,0 @@
-(module
- (memory (export "mem") 1 1)
-
- (func (export "load_i32") (param $a i32) (result i32)
- local.get $a
- i32.load)
-
- (func (export "store_i32") (param $a i32) (param $b i32)
- local.get $a
- local.get $b
- i32.store)
-)
diff --git a/crates/fuzzing/wasm-spec-interpreter/tests/oob.wat b/crates/fuzzing/wasm-spec-interpreter/tests/oob.wat
deleted file mode 100644
index e0fff3815b..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/tests/oob.wat
+++ /dev/null
@@ -1,6 +0,0 @@
-(module
- (memory (;0;) 0 0)
- (func (export "oob")
- i32.const 42
- f32.load align=1
- return))
diff --git a/crates/fuzzing/wasm-spec-interpreter/tests/shr_s.wat b/crates/fuzzing/wasm-spec-interpreter/tests/shr_s.wat
deleted file mode 100644
index c9733d766a..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/tests/shr_s.wat
+++ /dev/null
@@ -1,9 +0,0 @@
-(module
- (type (;0;) (func (param i32 i32) (result i32)))
- (func (;0;) (type 0) (param i32 i32) (result i32)
- local.get 0
- local.get 1
- i32.shr_s
- )
- (export "test" (func 0))
-)
diff --git a/crates/fuzzing/wasm-spec-interpreter/tests/simd_not.wat b/crates/fuzzing/wasm-spec-interpreter/tests/simd_not.wat
deleted file mode 100644
index 6ea48fa14d..0000000000
--- a/crates/fuzzing/wasm-spec-interpreter/tests/simd_not.wat
+++ /dev/null
@@ -1,4 +0,0 @@
-(module
- (func (export "simd_not") (param $a v128) (result v128)
- local.get $a
- v128.not))
diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs
index 98ef130d5c..c1aa69bf5e 100644
--- a/crates/wasmtime/src/config.rs
+++ b/crates/wasmtime/src/config.rs
@@ -305,7 +305,11 @@ impl Config {
wmemcheck: false,
#[cfg(feature = "coredump")]
coredump_on_trap: false,
- macos_use_mach_ports: !cfg!(miri),
+ // Disable mach ports on miri since it doesn't emulate those APIs,
+ // and additionally disable it with ASAN by default because
+ // otherwise mach ports routes around signal handlers installed by
+ // ASAN.
+ macos_use_mach_ports: !cfg!(miri) && !cfg!(asan),
#[cfg(feature = "std")]
detect_host_feature: Some(detect_host_feature),
#[cfg(not(feature = "std"))]
diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index a5d6780b33..12b839a4d1 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -48,8 +48,7 @@ wasmtime = { workspace = true }
wasmtime-test-util = { workspace = true, features = ['component-fuzz'] }
[features]
-default = ['fuzz-spec-interpreter', 'v8']
-fuzz-spec-interpreter = ['wasmtime-fuzzing/fuzz-spec-interpreter']
+default = ['v8']
v8 = ['wasmtime-fuzzing/v8']
chaos = ["cranelift-control/chaos"]
# Check the x64 assembler against Intel XED in the `misc` fuzzer. Off by default
diff --git a/fuzz/README.md b/fuzz/README.md
index 802133a92c..ae1cda7b16 100644
--- a/fuzz/README.md
+++ b/fuzz/README.md
@@ -61,8 +61,7 @@ At the time of writing, we have the following fuzz targets:
from scratch.
* `differential`: Generate a Wasm module, evaluate each exported function
with random inputs, and check that Wasmtime returns the same results as a
- choice of another engine: the Wasm spec interpreter (see the
- `wasm-spec-interpreter` crate), the `wasmi` interpreter, V8 (through the `v8`
+ choice of another engine: the `wasmi` interpreter, V8 (through the `v8`
crate), or Wasmtime itself run with a different configuration.
* `instantiate`: Generate a Wasm module and Wasmtime configuration and attempt
to compile and instantiate with them.
diff --git a/fuzz/fuzz_targets/differential.rs b/fuzz/fuzz_targets/differential.rs
index b949e7794a..116b51662a 100644
--- a/fuzz/fuzz_targets/differential.rs
+++ b/fuzz/fuzz_targets/differential.rs
@@ -30,8 +30,6 @@ static STATS: RuntimeStats = RuntimeStats::new();
fuzz_target!(|data: &[u8]| {
SETUP.call_once(|| {
- // To avoid a uncaught `SIGSEGV` due to signal handlers; see comments on
- // `setup_ocaml_runtime`.
engine::setup_engine_runtimes();
// Retrieve the configuration for this fuzz target from `ALLOWED_*`