MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / unwrap_instance

Function unwrap_instance

crates/fuzzing/src/oracles.rs:401–444  ·  view source on GitHub ↗
(
    store: &Store<StoreLimits>,
    instance: wasmtime::Result<Instance>,
)

Source from the content-addressed store, hash-verified

399}
400
401fn unwrap_instance(
402 store: &Store<StoreLimits>,
403 instance: wasmtime::Result<Instance>,
404) -> Option<Instance> {
405 let e = match instance {
406 Ok(i) => return Some(i),
407 Err(e) => e,
408 };
409
410 log::debug!("failed to instantiate: {e:?}");
411
412 // If the instantiation hit OOM for some reason then that's ok, it's
413 // expected that fuzz-generated programs try to allocate lots of
414 // stuff.
415 if store.data().is_oom() {
416 return None;
417 }
418
419 // Allow traps which can happen normally with `unreachable` or a timeout or
420 // such.
421 if e.is::<Trap>()
422 // Also allow failures to instantiate as a result of hitting pooling
423 // limits.
424 || e.is::<wasmtime::PoolConcurrencyLimitError>()
425 // And GC heap OOMs.
426 || e.is::<wasmtime::GcHeapOutOfMemory<()>>()
427 // And thrown exceptions.
428 || e.is::<wasmtime::ThrownException>()
429 {
430 return None;
431 }
432
433 let string = e.to_string();
434
435 // Currently we instantiate with a `Linker` which can't instantiate
436 // every single module under the sun due to using name-based resolution
437 // rather than positional-based resolution
438 if string.contains("incompatible import type") {
439 return None;
440 }
441
442 // Everything else should be a bug in the fuzzer or a bug in wasmtime
443 panic!("failed to instantiate: {e:?}");
444}
445
446/// Evaluate the function identified by `name` in two different engine
447/// instances--`lhs` and `rhs`.

Callers 2

instantiate_with_dummyFunction · 0.85
call_asyncFunction · 0.85

Calls 4

is_oomMethod · 0.45
dataMethod · 0.45
to_stringMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected