Skip to content

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

Reject attempts to create `ExnType`s when a GC runtime is not configured (#13486)

Nick Fitzgerald3471bf934287
diff --git a/crates/wasmtime/src/runtime/types.rs b/crates/wasmtime/src/runtime/types.rs
index 93051b7921..8dcdc2eeab 100644
--- a/crates/wasmtime/src/runtime/types.rs
+++ b/crates/wasmtime/src/runtime/types.rs
@@ -2839,6 +2839,11 @@ impl ExnType {
fields: impl IntoIterator<Item = ValType>,
func_ty: FuncType,
) -> Result<ExnType> {
+ ensure!(
+ engine.gc_runtime().is_some(),
+ "cannot define `ExnType`s without a GC runtime enabled"
+ );
+
let mut wasm_fields = TryVec::new();
for ty in fields.into_iter() {
assert!(ty.comes_from_same_engine(engine));
diff --git a/tests/all/tags.rs b/tests/all/tags.rs
index 3b45d2fec6..766fc23b1e 100644
--- a/tests/all/tags.rs
+++ b/tests/all/tags.rs
@@ -1,3 +1,4 @@
+use crate::ErrorExt;
use wasmtime::*;
#[test]
@@ -90,3 +91,19 @@ fn stack_switching_disallows_inlining() -> Result<()> {
assert!(Engine::new(&config).is_err());
return Ok(());
}
+
+#[test]
+#[cfg_attr(miri, ignore)]
+fn issue_13474_create_tag_without_gc_runtime_configured() -> Result<()> {
+ let mut config = Config::new();
+ config.strategy(Strategy::Winch);
+ let engine = Engine::new(&config)?;
+ let mut store = Store::new(&engine, ());
+ let fty = FuncType::new(&engine, [], []);
+ let tty1 = TagType::new(fty.clone());
+ let result = Tag::new(&mut store, &tty1.clone());
+ result
+ .unwrap_err()
+ .assert_contains("cannot define `ExnType`s without a GC runtime enabled");
+ Ok(())
+}