Skip to content

Commit

Permalink
Move define_unknown_imports_as_trap before instantiate
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles committed Jan 22, 2025
1 parent 9120028 commit c4b1f5a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
Expand Down

0 comments on commit c4b1f5a

Please sign in to comment.