Skip to content

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

"Downgrade" threads support to tier 2, disable fuzzing (#12036)

Alex Crichton0a55f8048cbd
diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h
index 172366f6a1..af5f3e0f06 100644
--- a/crates/c-api/include/wasmtime/config.h
+++ b/crates/c-api/include/wasmtime/config.h
@@ -147,13 +147,18 @@ WASMTIME_CONFIG_PROP(void, max_wasm_stack, size_t)
* \brief Configures whether the WebAssembly threading proposal is enabled.
*
* This setting is `false` by default.
- *
- * Note that threads are largely unimplemented in Wasmtime at this time.
*/
WASMTIME_CONFIG_PROP(void, wasm_threads, bool)
#endif // WASMTIME_FEATURE_THREADS
+/**
+ * \brief Configures whether shared memories can be created.
+ *
+ * This setting is `false` by default.
+ */
+WASMTIME_CONFIG_PROP(void, shared_memory, bool)
+
/**
* \brief Configures whether the WebAssembly tail call proposal is enabled.
*
diff --git a/crates/c-api/include/wasmtime/config.hh b/crates/c-api/include/wasmtime/config.hh
index e510e5b1b2..59d549899d 100644
--- a/crates/c-api/include/wasmtime/config.hh
+++ b/crates/c-api/include/wasmtime/config.hh
@@ -289,6 +289,13 @@ class Config {
}
#endif // WASMTIME_FEATURE_THREADS
+ /// \brief Configures whether wasm shared memories can be created.
+ ///
+ /// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.shared_memory
+ void shared_memory(bool enable) {
+ wasmtime_config_shared_memory_set(ptr.get(), enable);
+ }
+
/// \brief Configures whether the WebAssembly tail call proposal is enabled
///
/// https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.wasm_tail_call
diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs
index 1eb1c11038..57fa9c3409 100644
--- a/crates/c-api/src/config.rs
+++ b/crates/c-api/src/config.rs
@@ -79,6 +79,11 @@ pub extern "C" fn wasmtime_config_wasm_threads_set(c: &mut wasm_config_t, enable
c.config.wasm_threads(enable);
}
+#[unsafe(no_mangle)]
+pub extern "C" fn wasmtime_config_shared_memory_set(c: &mut wasm_config_t, enable: bool) {
+ c.config.shared_memory(enable);
+}
+
#[unsafe(no_mangle)]
pub extern "C" fn wasmtime_config_wasm_tail_call_set(c: &mut wasm_config_t, enable: bool) {
c.config.wasm_tail_call(enable);
diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs
index f5acb0c41a..ae595955e9 100644
--- a/crates/cli-flags/src/lib.rs
+++ b/crates/cli-flags/src/lib.rs
@@ -369,6 +369,8 @@ wasmtime_option_group! {
pub tail_call: Option<bool>,
/// Configure support for the threads proposal.
pub threads: Option<bool>,
+ /// Configure the ability to create a `shared` memory.
+ pub shared_memory: Option<bool>,
/// Configure support for the shared-everything-threads proposal.
pub shared_everything_threads: Option<bool>,
/// Configure support for the memory64 proposal.
@@ -1004,6 +1006,10 @@ impl CommonOptions {
config.gc_support(enable);
}
+ if let Some(enable) = self.wasm.shared_memory {
+ config.shared_memory(enable);
+ }
+
Ok(config)
}
diff --git a/crates/fuzzing/src/generators/config.rs b/crates/fuzzing/src/generators/config.rs
index ea1ca020b8..3a948117ea 100644
--- a/crates/fuzzing/src/generators/config.rs
+++ b/crates/fuzzing/src/generators/config.rs
@@ -308,6 +308,7 @@ impl Config {
Some(self.module_config.config.shared_everything_threads_enabled);
cfg.wasm.wide_arithmetic = Some(self.module_config.config.wide_arithmetic_enabled);
cfg.wasm.exceptions = Some(self.module_config.config.exceptions_enabled);
+ cfg.wasm.shared_memory = Some(self.module_config.shared_memory);
if !self.module_config.config.simd_enabled {
cfg.wasm.relaxed_simd = Some(false);
}
diff --git a/crates/fuzzing/src/generators/module.rs b/crates/fuzzing/src/generators/module.rs
index 942ff9fad8..58e10cf903 100644
--- a/crates/fuzzing/src/generators/module.rs
+++ b/crates/fuzzing/src/generators/module.rs
@@ -23,6 +23,7 @@ pub struct ModuleConfig {
pub component_model_error_context: bool,
pub component_model_gc: bool,
pub legacy_exceptions: bool,
+ pub shared_memory: bool,
}
impl<'a> Arbitrary<'a> for ModuleConfig {
@@ -53,7 +54,11 @@ impl<'a> Arbitrary<'a> for ModuleConfig {
config.custom_page_sizes_enabled = u.arbitrary()?;
config.wide_arithmetic_enabled = u.arbitrary()?;
config.memory64_enabled = u.ratio(1, 20)?;
- config.threads_enabled = u.ratio(1, 20)?;
+ // Fuzzing threads is an open question. Even without actual parallel
+ // threads `SharedMemory` still poses a problem where it isn't hooked
+ // into resource limits the same way `Memory` is. Overall not clear what
+ // to do so it's disabled for now.
+ config.threads_enabled = false;
// Allow multi-memory but make it unlikely
if u.ratio(1, 20)? {
config.max_memories = config.max_memories.max(2);
@@ -75,6 +80,7 @@ impl<'a> Arbitrary<'a> for ModuleConfig {
component_model_error_context: false,
component_model_gc: false,
legacy_exceptions: false,
+ shared_memory: false,
function_references_enabled: config.gc_enabled,
config,
})
diff --git a/crates/fuzzing/src/oracles.rs b/crates/fuzzing/src/oracles.rs
index 5b555633a2..fa9df31778 100644
--- a/crates/fuzzing/src/oracles.rs
+++ b/crates/fuzzing/src/oracles.rs
@@ -709,6 +709,7 @@ pub fn wast_test(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<()> {
crate::init_fuzzing();
let mut fuzz_config: generators::Config = u.arbitrary()?;
+ fuzz_config.module_config.shared_memory = true;
let test: generators::WastTest = u.arbitrary()?;
let test = &test.test;
@@ -1310,7 +1311,6 @@ mod tests {
| WasmFeatures::SIMD
| WasmFeatures::MULTI_MEMORY
| WasmFeatures::RELAXED_SIMD
- | WasmFeatures::THREADS
| WasmFeatures::TAIL_CALL
| WasmFeatures::WIDE_ARITHMETIC
| WasmFeatures::MEMORY64
diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs
index af9e16eebd..07fed8ccf8 100644
--- a/crates/wasmtime/src/config.rs
+++ b/crates/wasmtime/src/config.rs
@@ -164,6 +164,7 @@ pub struct Config {
pub(crate) macos_use_mach_ports: bool,
pub(crate) detect_host_feature: Option<fn(&str) -> Option<bool>>,
pub(crate) x86_float_abi_ok: Option<bool>,
+ pub(crate) shared_memory: bool,
}
/// User-provided configuration for the compiler.
@@ -273,6 +274,7 @@ impl Config {
#[cfg(not(feature = "std"))]
detect_host_feature: None,
x86_float_abi_ok: None,
+ shared_memory: false,
};
#[cfg(any(feature = "cranelift", feature = "winch"))]
{
@@ -2885,6 +2887,27 @@ impl Config {
self.x86_float_abi_ok = Some(enable);
self
}
+
+ /// Enable or disable the ability to create a
+ /// [`SharedMemory`](crate::SharedMemory).
+ ///
+ /// The WebAssembly threads proposal, configured by [`Config::wasm_threads`]
+ /// is on-by-default but there are enough deficiencies in Wasmtime's
+ /// implementation and API integration that creation of a shared memory is
+ /// disabled by default. This cofiguration knob can be used to enable this.
+ ///
+ /// When enabling this method be aware that wasm threads are, at this time,
+ /// a [tier 2
+ /// feature](https://docs.wasmtime.dev/stability-tiers.html#tier-2) in
+ /// Wasmtime meaning that it will not receive security updates or fixes to
+ /// historical releases. Additionally security CVEs will not be issued for
+ /// bugs in the implementation.
+ ///
+ /// This option is `false` by default.
+ pub fn shared_memory(&mut self, enable: bool) -> &mut Self {
+ self.shared_memory = enable;
+ self
+ }
}
impl Default for Config {
diff --git a/crates/wasmtime/src/runtime/memory.rs b/crates/wasmtime/src/runtime/memory.rs
index 96404b2d33..6ec6fef44a 100644
--- a/crates/wasmtime/src/runtime/memory.rs
+++ b/crates/wasmtime/src/runtime/memory.rs
@@ -777,8 +777,9 @@ pub unsafe trait MemoryCreator: Send + Sync {
/// used concurrently by multiple agents. Because these agents may execute in
/// different threads, [`SharedMemory`] must be thread-safe.
///
-/// When the threads proposal is enabled, there are multiple ways to construct
-/// shared memory:
+/// When the [threads proposal is enabled](crate::Config::wasm_threads) and the
+/// [the creation of shared memories is enabled](crate::Config::shared_memory),
+/// there are multiple ways to construct shared memory:
/// 1. for imported shared memory, e.g., `(import "env" "memory" (memory 1 1
/// shared))`, the user must supply a [`SharedMemory`] with the
/// externally-created memory as an import to the instance--e.g.,
@@ -797,6 +798,7 @@ pub unsafe trait MemoryCreator: Send + Sync {
/// # fn main() -> anyhow::Result<()> {
/// let mut config = Config::new();
/// config.wasm_threads(true);
+/// config.shared_memory(true);
/// # if Engine::new(&config).is_err() { return Ok(()); }
/// let engine = Engine::new(&config)?;
/// let mut store = Store::new(&engine, ());
@@ -825,9 +827,8 @@ impl SharedMemory {
}
debug_assert!(ty.maximum().is_some());
- let tunables = engine.tunables();
let ty = ty.wasmtime_memory();
- let memory = crate::runtime::vm::SharedMemory::new(ty, tunables)?;
+ let memory = crate::runtime::vm::SharedMemory::new(engine, ty)?;
Ok(Self {
vm: memory,
diff --git a/crates/wasmtime/src/runtime/vm/instance/allocator/on_demand.rs b/crates/wasmtime/src/runtime/vm/instance/allocator/on_demand.rs
index 0373ac30c4..cbcfec3dfc 100644
--- a/crates/wasmtime/src/runtime/vm/instance/allocator/on_demand.rs
+++ b/crates/wasmtime/src/runtime/vm/instance/allocator/on_demand.rs
@@ -129,7 +129,7 @@ unsafe impl InstanceAllocator for OnDemandInstanceAllocator {
let allocation_index = MemoryAllocationIndex::default();
let memory = Memory::new_dynamic(
ty,
- request.store.engine().tunables(),
+ request.store.engine(),
creator,
image,
request.limiter.as_deref_mut(),
diff --git a/crates/wasmtime/src/runtime/vm/memory.rs b/crates/wasmtime/src/runtime/vm/memory.rs
index 92db142c82..11ca43ec82 100644
--- a/crates/wasmtime/src/runtime/vm/memory.rs
+++ b/crates/wasmtime/src/runtime/vm/memory.rs
@@ -74,6 +74,7 @@
//! FIXME: don't have both RuntimeMemoryCreator and wasmtime::MemoryCreator,
//! they should be merged together.
+use crate::Engine;
use crate::prelude::*;
use crate::runtime::store::StoreResourceLimiter;
use crate::runtime::vm::vmcontext::VMMemoryDefinition;
@@ -233,17 +234,18 @@ impl Memory {
/// Create a new dynamic (movable) memory instance for the specified plan.
pub async fn new_dynamic(
ty: &wasmtime_environ::Memory,
- tunables: &Tunables,
+ engine: &Engine,
creator: &dyn RuntimeMemoryCreator,
memory_image: Option<&Arc<MemoryImage>>,
limiter: Option<&mut StoreResourceLimiter<'_>>,
) -> Result<Self> {
let (minimum, maximum) = Self::limit_new(ty, limiter).await?;
+ let tunables = engine.tunables();
let allocation = creator.new_memory(ty, tunables, minimum, maximum)?;
let memory = LocalMemory::new(ty, tunables, allocation, memory_image)?;
Ok(if ty.shared {
- Memory::Shared(SharedMemory::wrap(ty, memory)?)
+ Memory::Shared(SharedMemory::wrap(engine, ty, memory)?)
} else {
Memory::Local(memory)
})
diff --git a/crates/wasmtime/src/runtime/vm/memory/shared_memory.rs b/crates/wasmtime/src/runtime/vm/memory/shared_memory.rs
index a1abe2d644..5cafea3693 100644
--- a/crates/wasmtime/src/runtime/vm/memory/shared_memory.rs
+++ b/crates/wasmtime/src/runtime/vm/memory/shared_memory.rs
@@ -1,3 +1,4 @@
+use crate::Engine;
use crate::prelude::*;
use crate::runtime::vm::memory::{LocalMemory, MmapMemory, validate_atomic_addr};
use crate::runtime::vm::parking_spot::{ParkingSpot, Waiter};
@@ -8,7 +9,7 @@ use std::ptr::NonNull;
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
use std::sync::{Arc, RwLock};
use std::time::{Duration, Instant};
-use wasmtime_environ::{Trap, Tunables};
+use wasmtime_environ::Trap;
/// For shared memory (and only for shared memory), this lock-version restricts
/// access when growing the memory or checking its size. This is to conform with
@@ -30,19 +31,30 @@ struct SharedMemoryInner {
impl SharedMemory {
/// Construct a new [`SharedMemory`].
- pub fn new(ty: &wasmtime_environ::Memory, tunables: &Tunables) -> Result<Self> {
+ pub fn new(engine: &Engine, ty: &wasmtime_environ::Memory) -> Result<Self> {
+ let tunables = engine.tunables();
// Note that without a limiter being passed to `limit_new` this
// `assert_ready` should never panic.
let (minimum_bytes, maximum_bytes) = vm::assert_ready(Memory::limit_new(ty, None))?;
let mmap_memory = MmapMemory::new(ty, tunables, minimum_bytes, maximum_bytes)?;
Self::wrap(
+ engine,
ty,
LocalMemory::new(ty, tunables, Box::new(mmap_memory), None)?,
)
}
/// Wrap an existing [Memory] with the locking provided by a [SharedMemory].
- pub fn wrap(ty: &wasmtime_environ::Memory, memory: LocalMemory) -> Result<Self> {
+ pub fn wrap(
+ engine: &Engine,
+ ty: &wasmtime_environ::Memory,
+ memory: LocalMemory,
+ ) -> Result<Self> {
+ if !engine.config().shared_memory {
+ bail!(
+ "shared memory support is disabled for this engine -- see `Config::shared_memory`"
+ );
+ }
if !ty.shared {
bail!("shared memory must have a `shared` memory type");
}
diff --git a/crates/wasmtime/src/runtime/vm/memory/shared_memory_disabled.rs b/crates/wasmtime/src/runtime/vm/memory/shared_memory_disabled.rs
index c85095e625..960d35efb8 100644
--- a/crates/wasmtime/src/runtime/vm/memory/shared_memory_disabled.rs
+++ b/crates/wasmtime/src/runtime/vm/memory/shared_memory_disabled.rs
@@ -1,3 +1,4 @@
+use crate::Engine;
use crate::prelude::*;
use crate::runtime::vm::memory::LocalMemory;
use crate::runtime::vm::{VMMemoryDefinition, WaitResult};
@@ -10,7 +11,7 @@ use wasmtime_environ::Trap;
pub enum SharedMemory {}
impl SharedMemory {
- pub fn wrap(_ty: &wasmtime_environ::Memory, _memory: LocalMemory) -> Result<Self> {
+ pub fn wrap(_: &Engine, _ty: &wasmtime_environ::Memory, _memory: LocalMemory) -> Result<Self> {
bail!("support for shared memories was disabled at compile time");
}
diff --git a/docs/stability-tiers.md b/docs/stability-tiers.md
index 44531f86bd..94e57850ba 100644
--- a/docs/stability-tiers.md
+++ b/docs/stability-tiers.md
@@ -37,7 +37,6 @@ For explanations of what each tier means see below.
| WebAssembly Proposal | [`component-model`] |
| WebAssembly Proposal | [`relaxed-simd`] |
| WebAssembly Proposal | [`multi-memory`] |
-| WebAssembly Proposal | [`threads`] |
| WebAssembly Proposal | [`tail-call`] |
| WebAssembly Proposal | [`extended-const`] |
| WebAssembly Proposal | [`memory64`] |
@@ -81,11 +80,12 @@ For explanations of what each tier means see below.
| Target | `s390x-unknown-linux-gnu` | Continuous fuzzing |
| Target | `x86_64-pc-windows-gnu` | Clear owner of the target |
| Target | Support for `#![no_std]` | Support beyond CI checks |
+| WebAssembly Proposal | [`custom-page-sizes`] | Unstable wasm proposal |
+| WebAssembly Proposal | [`exception-handling`] | fuzzing, dependence on GC |
| WebAssembly Proposal | [`function-references`] | production quality |
| WebAssembly Proposal | [`gc`] | production quality |
+| WebAssembly Proposal | [`threads`] | fuzzing, API quality |
| WebAssembly Proposal | [`wide-arithmetic`] | Unstable wasm proposal |
-| WebAssembly Proposal | [`custom-page-sizes`] | Unstable wasm proposal |
-| WebAssembly Proposal | [`exception-handling`] | fuzzing, dependence on GC |
| Execution Backend | Pulley | More time fuzzing/baking |
| Embedding API | C++ | Full-time maintainer |
diff --git a/docs/stability-wasm-proposals.md b/docs/stability-wasm-proposals.md
index 40867ed93b..a0503a212a 100644
--- a/docs/stability-wasm-proposals.md
+++ b/docs/stability-wasm-proposals.md
@@ -5,7 +5,7 @@ proposals in Wasmtime. For information about implementing a proposal in Wasmtime
see the [associated
documentation](./contributing-implementing-wasm-proposals.md).
-WebAssembly proposals that want to be [tier 2 or above](./stability-tiers.md)
+WebAssembly proposals that want to be [tier 1](./stability-tiers.md)
are required to check all boxes in this matrix. An explanation of each matrix
column is below.
@@ -15,7 +15,7 @@ The emoji legend is:
* 🚧 - work-in-progress
* ❌ - not supported yet
-## On-by-default proposals
+## Tier 1 WebAssembly Proposals
| Proposal | Phase 4 | Tests | Finished | Fuzzed | API | C API |
|--------------------------|---------|-------|----------|--------|-----|-------|
@@ -26,10 +26,9 @@ The emoji legend is:
| [`bulk-memory`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`reference-types`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`simd`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
-| [`component-model`] | ❌[^1] | βœ… | βœ… | 🚧[^2] | βœ… | 🚧[^5]|
+| [`component-model`] | ❌[^1] | βœ… | βœ… | 🚧[^2] | βœ… | 🚧[^3]|
| [`relaxed-simd`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`multi-memory`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
-| [`threads`] | βœ… | βœ… | βœ…[^9] | ❌[^3] | βœ… | βœ… |
| [`tail-call`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`extended-const`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
| [`memory64`] | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
@@ -38,50 +37,60 @@ The emoji legend is:
process but it is still enabled-by-default in Wasmtime.
[^2]: Various shapes of components are fuzzed but full-on fuzzing along the
lines of `wasm-smith` are not implemented for components.
-[^3]: Fuzzing with threads is an open implementation question that is expected
- to get fleshed out as the [`shared-everything-threads`] proposal advances.
-[^5]: The component model is mostly supported in the C API but [gaps
+[^3]: The component model is mostly supported in the C API but [gaps
remain][cm-capi-gaps].
-[^9]: There are [known
- issues](https://github.com/bytecodealliance/wasmtime/issues/4245) with
- shared memories and the implementation/API in Wasmtime, for example they
- aren't well integrated with resource-limiting features in `Store`.
- Additionally `shared` memories aren't supported in the pooling allocator.
[cm-capi-gaps]: https://github.com/bytecodealliance/wasmtime/issues?q=is%3Aissue%20state%3Aopen%20label%3Awasm-proposal%3Acomponent-model%20label%3Awasmtime%3Ac-api
-## Off-by-default proposals
+## Tier 2 WebAssembly Proposals
-| Proposal | Phase 4 | Tests | Finished | Fuzzed | API | C API |
-|-----------------------------|---------|-------|----------|--------|-----|--------|
-| [`function-references`] | βœ… | βœ… | βœ… | 🚧 | βœ… | ❌ |
-| [`gc`] [^6] | βœ… | βœ… | 🚧[^7] | 🚧[^8] | βœ… | ❌ |
-| [`wide-arithmetic`] | ❌ | βœ… | βœ… | βœ… | βœ… | βœ… |
-| [`custom-page-sizes`] | ❌ | βœ… | βœ… | βœ… | βœ… | βœ… |
-| [`exception-handling`] | βœ… | βœ… | βœ… | 🚧[^11]| βœ… | 🚧[^12]|
-| [`stack-switching`] [^10] | ❌ | 🚧 | 🚧 | ❌ | ❌ | ❌ |
+| Proposal | Phase 4 | Tests | Finished | Fuzzed | API | C API |
+|--------------------------|---------|-------|----------|--------|-----|--------|
+| [`custom-page-sizes`] | ❌ | βœ… | βœ… | βœ… | βœ… | βœ… |
+| [`exception-handling`] | βœ… | βœ… | βœ… | ❌ | βœ… | ❌ |
+| [`exception-handling`] | βœ… | βœ… | βœ… | 🚧[^9] | βœ… | 🚧[^10]|
+| [`function-references`] | βœ… | βœ… | βœ… | 🚧 | βœ… | ❌ |
+| [`gc`] [^5] | βœ… | βœ… | 🚧[^6] | 🚧[^7] | βœ… | ❌ |
+| [`threads`] | βœ… | βœ… | 🚧[^8] | ❌[^4] | βœ… | βœ… |
+| [`wide-arithmetic`] | ❌ | βœ… | βœ… | βœ… | βœ… | βœ… |
-[^6]: There is also a [tracking
+[^4]: Fuzzing with threads is an open implementation question that is expected
+ to get fleshed out as the [`shared-everything-threads`] proposal advances.
+[^5]: There is also a [tracking
issue](https://github.com/bytecodealliance/wasmtime/issues/5032) for the
GC proposal.
-[^7]: The implementation of Wasm GC is feature complete from a specification
+[^6]: The implementation of Wasm GC is feature complete from a specification
perspective, however a number of quality-of-implementation tasks
[remain](https://github.com/bytecodealliance/wasmtime/issues/5032), notably
a tracing collector that can reclaim garbage cycles.
-[^8]: The GC proposal is lightly fuzzed via `wasm-smith` and our usual
+[^7]: The GC proposal is lightly fuzzed via `wasm-smith` and our usual
whole-module fuzz targets like `differential`, but we would like to
additionally [extend the `table_ops` fuzz target to exercise more of the GC
proposal](https://github.com/bytecodealliance/wasmtime/issues/10327).
-[^10]: The stack-switching proposal is a work-in-progress being tracked
- at [#9465](https://github.com/bytecodealliance/wasmtime/issues/9465).
- Currently the implementation is only for x86\_64 Linux.
-[^11]: The exception-handling proposal is fuzzed by our whole-module fuzzer,
- but we do not have an exception-specific fuzzer that attempts to create
- interesting throw/catch patterns or payloads.
-[^12]: The exception-handling proposal can be enabled for exceptions in the guest
+[^8]: There are [known
+ issues](https://github.com/bytecodealliance/wasmtime/issues/4245) with
+ shared memories and the implementation/API in Wasmtime, for example they
+ aren't well integrated with resource-limiting features in `Store`.
+ Additionally `shared` memories aren't supported in the pooling allocator.
+[^9]: The exception-handling proposal is fuzzed by our whole-module fuzzer,
+ but we do not have an exception-specific fuzzer that attempts to create
+ interesting throw/catch patterns or payloads.
+[^10]: The exception-handling proposal can be enabled for exceptions in the guest
via the C API, but exception objects have no C API to examine, clone,
rethrow, or drop exceptions that propagate to the host.
+[cm-capi-gaps]: https://github.com/bytecodealliance/wasmtime/issues?q=is%3Aissue%20state%3Aopen%20label%3Awasm-proposal%3Acomponent-model%20label%3Awasmtime%3Ac-api
+
+## Tier 3 WebAssembly Proposals
+
+| Proposal | Phase 4 | Tests | Finished | Fuzzed | API | C API |
+|-----------------------------|---------|-------|----------|--------|-----|-------|
+| [`stack-switching`] [^11] | ❌ | 🚧 | 🚧 | ❌ | ❌ | ❌ |
+
+[^11]: The stack-switching proposal is a work-in-progress being tracked
+ at [#9465](https://github.com/bytecodealliance/wasmtime/issues/9465).
+ Currently the implementation is only for x86\_64 Linux.
+
## Unimplemented proposals
| Proposal | Tracking Issue |
@@ -156,4 +165,8 @@ For each column in the above tables, this is a further explanation of its meanin
* **C API** - The proposal's functionality is exposed in the C API.
+* **Enabled** - Whether or not this feature is on-by-default. Off-by-default
+ features require an opt-in on the CLI or via the embedding API to use, but
+ on-by-default features require no explicit action to use the feature.
+
[phases]: https://github.com/WebAssembly/meetings/blob/master/process/phases.md
diff --git a/src/commands/wast.rs b/src/commands/wast.rs
index e136987f74..00329ce9d5 100644
--- a/src/commands/wast.rs
+++ b/src/commands/wast.rs
@@ -48,6 +48,7 @@ impl WastCommand {
let async_ = optional_flag_with_default(self.async_, true);
let mut config = self.common.config(None)?;
config.async_support(async_);
+ config.shared_memory(true);
let engine = Engine::new(&config)?;
let mut wast_context = WastContext::new(
&engine,
diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs
index 768204f917..9c3f61fcab 100644
--- a/tests/all/cli_tests.rs
+++ b/tests/all/cli_tests.rs
@@ -563,7 +563,7 @@ fn run_threads() -> Result<()> {
let wasm = build_wasm("tests/all/cli_tests/threads.wat")?;
let stdout = run_wasmtime(&[
"run",
- "-Wthreads",
+ "-Wthreads,shared-memory",
"-Sthreads",
"-Ccache=n",
wasm.path().to_str().unwrap(),
diff --git a/tests/all/coredump.rs b/tests/all/coredump.rs
index c2375e4549..86b4da8eed 100644
--- a/tests/all/coredump.rs
+++ b/tests/all/coredump.rs
@@ -268,6 +268,7 @@ fn core_dump_with_shared_memory() -> Result<()> {
}
let mut config = Config::new();
config.coredump_on_trap(true);
+ config.shared_memory(true);
let engine = Engine::new(&config)?;
let mut store = Store::new(&engine, ());
let wat = r#"(module
diff --git a/tests/all/memory.rs b/tests/all/memory.rs
index 8158b944d9..57d7501bc8 100644
--- a/tests/all/memory.rs
+++ b/tests/all/memory.rs
@@ -566,7 +566,9 @@ fn memory64_maximum_minimum(config: &mut Config) -> Result<()> {
#[test]
fn shared_memory_basics() -> Result<()> {
- let engine = Engine::default();
+ let mut config = Config::new();
+ config.shared_memory(true);
+ let engine = Engine::new(&config)?;
assert!(SharedMemory::new(&engine, MemoryType::new(1, None)).is_err());
assert!(SharedMemory::new(&engine, MemoryType::new(1, Some(1))).is_err());
assert!(SharedMemory::new(&engine, MemoryType::new64(1, None)).is_err());
@@ -639,7 +641,9 @@ fn shared_memory_wait_notify() -> Result<()> {
const THREADS: usize = 8;
const COUNT: usize = 100_000;
- let engine = Engine::default();
+ let mut config = Config::new();
+ config.shared_memory(true);
+ let engine = Engine::new(&config)?;
let memory = SharedMemory::new(&engine, MemoryType::shared(1, 1))?;
let data = unsafe { AtomicU32::from_ptr(memory.data().as_ptr().cast_mut().cast()) };
let locked = unsafe { AtomicU32::from_ptr(memory.data().as_ptr().add(4).cast_mut().cast()) };
diff --git a/tests/all/native_debug/lldb.rs b/tests/all/native_debug/lldb.rs
index cc5b5c4ba9..9d30f51d3b 100644
--- a/tests/all/native_debug/lldb.rs
+++ b/tests/all/native_debug/lldb.rs
@@ -449,7 +449,12 @@ check: exited with status = 0
fn test_dwarf_simple(wasm: &str, extra_args: &[&str]) -> Result<()> {
println!("testing {wasm:?}");
- let mut args = vec!["-Ccache=n", "-Oopt-level=0", "-Ddebug-info"];
+ let mut args = vec![
+ "-Ccache=n",
+ "-Oopt-level=0",
+ "-Ddebug-info",
+ "-Wshared-memory",
+ ];
args.extend(extra_args);
args.push(wasm);
let output = lldb_with_script(
diff --git a/tests/all/threads.rs b/tests/all/threads.rs
index ef320b9382..90d4316f58 100644
--- a/tests/all/threads.rs
+++ b/tests/all/threads.rs
@@ -10,6 +10,7 @@ use wasmtime::*;
pub fn engine() -> Option<Engine> {
let mut config = Config::new();
config.wasm_threads(true);
+ config.shared_memory(true);
match Engine::new(&config) {
Ok(engine) => {
assert!(cfg!(target_pointer_width = "64"));
@@ -22,6 +23,23 @@ pub fn engine() -> Option<Engine> {
}
}
+#[test]
+#[cfg_attr(miri, ignore)]
+fn shared_memory_failed_creation() -> Result<()> {
+ let mut config = Config::new();
+ config.wasm_threads(true);
+ config.shared_memory(false);
+ let Ok(engine) = Engine::new(&config) else {
+ return Ok(());
+ };
+ assert!(SharedMemory::new(&engine, MemoryType::shared(1, 1)).is_err());
+ let wat = r#"(module (memory 1 1 shared))"#;
+ let module = Module::new(&engine, wat)?;
+ let mut store = Store::new(&engine, ());
+ assert!(Instance::new(&mut store, &module, &[]).is_err());
+ Ok(())
+}
+
#[test]
#[cfg_attr(miri, ignore)]
fn test_instantiate_shared_memory() -> Result<()> {
diff --git a/tests/wast.rs b/tests/wast.rs
index 519379edae..df84b55eeb 100644
--- a/tests/wast.rs
+++ b/tests/wast.rs
@@ -141,6 +141,7 @@ fn run_wast(test: &WastTest, config: WastConfig) -> anyhow::Result<()> {
let mut cfg = Config::new();
cfg.async_support(true);
+ cfg.shared_memory(true);
wasmtime_test_util::wasmtime_wast::apply_test_config(&mut cfg, &test_config);
wasmtime_test_util::wasmtime_wast::apply_wast_config(&mut cfg, &config);