Skip to content

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

Exceptions: properly root exception-type index in Tag. (#14009)

Chris Fallinef6ff5ef0696
diff --git a/crates/wasmtime/src/runtime/trampoline/table.rs b/crates/wasmtime/src/runtime/trampoline/table.rs
index 4f1ec8deca..fc1ddd6f05 100644
--- a/crates/wasmtime/src/runtime/trampoline/table.rs
+++ b/crates/wasmtime/src/runtime/trampoline/table.rs
@@ -40,7 +40,7 @@ pub async fn create_table(
AllocateInstanceKind::Dummy {
allocator: &allocator,
},
- &ModuleRuntimeInfo::bare_with_registered_type(
+ &ModuleRuntimeInfo::bare_with_registered_types(
module,
table.element().clone().into_registered_type(),
)?,
diff --git a/crates/wasmtime/src/runtime/trampoline/tag.rs b/crates/wasmtime/src/runtime/trampoline/tag.rs
index 4f7a1d898f..46e2028b6e 100644
--- a/crates/wasmtime/src/runtime/trampoline/tag.rs
+++ b/crates/wasmtime/src/runtime/trampoline/tag.rs
@@ -42,12 +42,19 @@ pub fn create_tag(store: &mut StoreOpaque, ty: &TagType) -> Result<InstanceId> {
// doesn't allocate tables or memories meaning it shouldn't need a
// resource limiter so `None` is passed. As a result no `await` points
// should ever be hit.
+ //
+ // Both the tag's signature type and its exception type are
+ // referred to by engine-level type index from the dummy
+ // module's `Tag`, so both `RegisteredType`s must be handed to
+ // the instance's runtime info to keep those indices rooted in
+ // the engine's type registry for as long as the instance (and
+ // thus the store) is alive.
vm::assert_ready(store.allocate_instance(
None,
AllocateInstanceKind::Dummy {
allocator: &allocator,
},
- &ModuleRuntimeInfo::bare_with_registered_type(module, Some(func_ty))?,
+ &ModuleRuntimeInfo::bare_with_registered_types(module, [func_ty, exn_ty])?,
imports,
))
}
diff --git a/crates/wasmtime/src/runtime/vm.rs b/crates/wasmtime/src/runtime/vm.rs
index 7c55158b97..d57e18cceb 100644
--- a/crates/wasmtime/src/runtime/vm.rs
+++ b/crates/wasmtime/src/runtime/vm.rs
@@ -297,26 +297,25 @@ pub enum ModuleRuntimeInfo {
/// cases where a purpose-built environ::Module is used and a full
/// CompiledModule does not exist (for example, for tests or for the
/// default-callee instance).
-#[derive(Clone)]
pub struct BareModuleInfo {
module: Arc<wasmtime_environ::Module>,
offsets: VMOffsets<HostPtr>,
- _registered_type: Option<RegisteredType>,
+ _registered_types: TryVec<RegisteredType>,
}
impl ModuleRuntimeInfo {
pub(crate) fn bare(module: Arc<wasmtime_environ::Module>) -> Result<Self, OutOfMemory> {
- ModuleRuntimeInfo::bare_with_registered_type(module, None)
+ ModuleRuntimeInfo::bare_with_registered_types(module, None)
}
- pub(crate) fn bare_with_registered_type(
+ pub(crate) fn bare_with_registered_types(
module: Arc<wasmtime_environ::Module>,
- registered_type: Option<RegisteredType>,
+ registered_types: impl IntoIterator<Item = RegisteredType>,
) -> Result<Self, OutOfMemory> {
let info = try_new(BareModuleInfo {
offsets: VMOffsets::new(HostPtr, &module),
module,
- _registered_type: registered_type,
+ _registered_types: registered_types.into_iter().try_collect()?,
})?;
Ok(ModuleRuntimeInfo::Bare(info))
}