From c4b1f5a5098c9305a115dcb96058621702a5cd48 Mon Sep 17 00:00:00 2001 From: Jeff Charles Date: Wed, 22 Jan 2025 09:35:45 -0500 Subject: [PATCH] Move define_unknown_imports_as_trap before instantiate --- crates/runner/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs index ce500d7d..b6947fd4 100644 --- a/crates/runner/src/lib.rs +++ b/crates/runner/src/lib.rs @@ -669,9 +669,13 @@ impl Runner { if let Some((name, bytes)) = &self.preload { let module = Module::from_binary(self.linker.engine(), bytes)?; + // `test-plugin` contains an imported function to test whether we + // can build a Javy module when an imported function is present in + // the plugin. The test itself doesn't call the imported function + // so we can safely trap if it's called. + self.linker.define_unknown_imports_as_traps(&module)?; let instance = self.linker.instantiate(store.as_context_mut(), &module)?; self.linker.allow_shadowing(true); - self.linker.define_unknown_imports_as_traps(&module)?; self.linker .instance(store.as_context_mut(), name, instance)?; }