Skip to content

Commit

Permalink
Log module errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ark0f committed Oct 3, 2024
1 parent fb7dae0 commit 10286e0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sandbox/sandbox/src/embedded_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ impl<T> super::SandboxMemory<T> for Memory {
fn new(store: &mut Store<T>, initial: u32, maximum: Option<u32>) -> Result<Memory, Error> {
let ty = MemoryType::new(initial, maximum, false);
let memory_style = store.engine().tunables().memory_style(&ty);
let memref = VMMemory::new(&ty, &memory_style).map_err(|_| Error::Module)?;
let memref = VMMemory::new(&ty, &memory_style).map_err(|e| {
log::trace!("Failed to create memory: {e}");
Error::Module
})?;
// SAFETY: `vmmemory()` returns `NonNull` so pointer is valid
let memory_definition = unsafe { memref.vmmemory().as_ref() };
let base = memory_definition.base as usize;
Expand Down Expand Up @@ -437,7 +440,10 @@ impl<State: Send + 'static> super::SandboxInstance<State> for Instance<State> {
.get(&key)
.cloned()
.and_then(|val| val.memory())
.ok_or(Error::Module)?
.ok_or_else(|| {
log::trace!("Memory import for `{module}::{name}` not found");
Error::Module
})?
.memref;
imports.define(&module, &name, mem);
}
Expand All @@ -447,7 +453,10 @@ impl<State: Send + 'static> super::SandboxInstance<State> for Instance<State> {
.get(&key)
.cloned()
.and_then(|val| val.host_func())
.ok_or(Error::Module)?;
.ok_or_else(|| {
log::trace!("Function import for `{module}::{name}` not found");
Error::Module
})?;

let func_ty = func_ty.clone();

Expand Down

0 comments on commit 10286e0

Please sign in to comment.