Skip to content

Commit

Permalink
Fix some more fuzz-test cases from pooling changes (bytecodealliance#…
Browse files Browse the repository at this point in the history
…6943)

* Fix some warnings on nightly Rust

* Fix some more fuzz-test cases from pooling changes

This commit addresses some more fallout from bytecodealliance#6835 by updating some
error messages and adding clauses for new conditions. Namely:

* Module compilation is now allowed to fail when the module may have
  more memories/tables than the pooling allocator allows per-module.
* The error message for the core instance limit being reached has been
  updated.
  • Loading branch information
alexcrichton authored Aug 31, 2023
1 parent c4db8b2 commit 1a11e25
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
23 changes: 19 additions & 4 deletions crates/fuzzing/src/oracles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ fn compile_module(
Ok(module) => Some(module),
Err(_) if !known_valid => None,
Err(e) => {
if let generators::InstanceAllocationStrategy::Pooling { .. } =
&config.wasmtime.strategy
{
if let generators::InstanceAllocationStrategy::Pooling(c) = &config.wasmtime.strategy {
// When using the pooling allocator, accept failures to compile
// when arbitrary table element limits have been exceeded as
// there is currently no way to constrain the generated module
Expand All @@ -275,6 +273,23 @@ fn compile_module(
if string.contains("instance allocation for this module requires") {
return None;
}

// If the pooling allocator is more restrictive on the number of
// tables and memories than we allowed wasm-smith to generate
// then allow compilation errors along those lines.
if c.max_tables_per_module < (config.module_config.config.max_tables as u32)
&& string.contains("defined tables count")
&& string.contains("exceeds the per-instance limit")
{
return None;
}

if c.max_memories_per_module < (config.module_config.config.max_memories as u32)
&& string.contains("defined memories count")
&& string.contains("exceeds the per-instance limit")
{
return None;
}
}

panic!("failed to compile module: {:?}", e);
Expand Down Expand Up @@ -329,7 +344,7 @@ pub fn instantiate_with_dummy(store: &mut Store<StoreLimits>, module: &Module) -
}

// Also allow failures to instantiate as a result of hitting pooling limits.
if string.contains("maximum concurrent instance limit")
if string.contains("maximum concurrent core instance limit")
|| string.contains("maximum concurrent memory limit")
|| string.contains("maximum concurrent table limit")
{
Expand Down
2 changes: 1 addition & 1 deletion crates/jit/src/unwind/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
pub struct UnwindRegistration {}

impl UnwindRegistration {
pub const SECTION_NAME: &str = ".eh_frame";
pub const SECTION_NAME: &'static str = ".eh_frame";

pub unsafe fn new(
_base_address: *const u8,
Expand Down
2 changes: 1 addition & 1 deletion crates/jit/src/unwind/systemv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" {
}

impl UnwindRegistration {
pub const SECTION_NAME: &str = ".eh_frame";
pub const SECTION_NAME: &'static str = ".eh_frame";

/// Registers precompiled unwinding information with the system.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/jit/src/unwind/winx64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct UnwindRegistration {
}

impl UnwindRegistration {
pub const SECTION_NAME: &str = ".pdata";
pub const SECTION_NAME: &'static str = ".pdata";

pub unsafe fn new(
base_address: *const u8,
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/instantiate-many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const MAX_MODULES: usize = 5;
fuzz_target!(|data: &[u8]| {
// errors in `run` have to do with not enough input in `data`, which we
// ignore here since it doesn't affect how we'd like to fuzz.
drop(execute_one(data));
let _ = execute_one(data);
});

fn execute_one(data: &[u8]) -> Result<()> {
Expand Down

0 comments on commit 1a11e25

Please sign in to comment.