Skip to content

Commit

Permalink
More fuzz tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed May 17, 2024
1 parent 8c4b969 commit 8f307a7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/fuzzing/src/generators/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ impl<'a> Arbitrary<'a> for Config {
// If using the pooling allocator, constrain the memory and module configurations
// to the module limits.
if let InstanceAllocationStrategy::Pooling(pooling) = &mut config.wasmtime.strategy {
// Forcibly don't use the `CustomUnaligned` memory configuration
// with the pooling allocator active.
if let MemoryConfig::CustomUnaligned = config.wasmtime.memory_config {
config.wasmtime.memory_config = MemoryConfig::Normal(u.arbitrary()?);
}

let cfg = &mut config.module_config.config;
// If the pooling allocator is used, do not allow shared memory to
// be created. FIXME: see
Expand All @@ -438,19 +444,19 @@ impl<'a> Arbitrary<'a> for Config {
pooling.max_memory_size = 1 << 16;
cfg.max_memory32_pages = 1;
cfg.max_memory64_pages = 1;
if let MemoryConfig::Normal(cfg) = &mut config.wasmtime.memory_config {
match &mut cfg.static_memory_maximum_size {
Some(size) => *size = (*size).max(pooling.max_memory_size as u64),
size @ None => *size = Some(pooling.max_memory_size as u64),
}
}
}
// .. additionally update tables
if pooling.table_elements == 0 {
pooling.table_elements = 1;
}
}

// Forcibly don't use the `CustomUnaligned` memory configuration
// with the pooling allocator active.
if let MemoryConfig::CustomUnaligned = config.wasmtime.memory_config {
config.wasmtime.memory_config = MemoryConfig::Normal(u.arbitrary()?);
}

// Don't allow too many linear memories per instance since massive
// virtual mappings can fail to get allocated.
cfg.min_memories = cfg.min_memories.min(10);
Expand Down

0 comments on commit 8f307a7

Please sign in to comment.