From a263a4ff06e9662fbfdbc33efe0cd4b8b101b78c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 10 Jul 2026 14:09:44 -0700 Subject: [PATCH 1/2] fix --- src/tools/fuzzing/fuzzing.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 66e898c2954..8ed6e58e1a8 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -906,16 +906,21 @@ void TranslateToFuzzReader::finalizeMemory() { } memory->initial = std::max(memory->initial, fuzzParams->USABLE_MEMORY); // Avoid an unlimited memory size, which would make fuzzing very difficult - // as different VMs will run out of system memory in different ways. - if (memory->max == Memory::kUnlimitedSize) { + // as different VMs will run out of system memory in different ways. Also use + // the initial memory size as the maximum, if the initial is now larger + // (which can happen as we compute the initial size, above: this is where we + // update the maximum to make sense relative to that new initial size). + if (memory->max == Memory::kUnlimitedSize || memory->max < memory->initial) { memory->max = memory->initial; } - if (memory->max <= memory->initial) { + if (memory->max == memory->initial && oneIn(2)) { // To allow growth to work (which a testcase may assume), try to make the - // maximum larger than the initial. + // maximum larger than the initial, some of the time. // TODO: scan the wasm for grow instructions? memory->max = - std::min(Address(memory->initial + 1), Address(memory->maxSize32())); + std::min(Address(memory->initial + 1), + Address(memory->is64() ? memory->maxSize64() + : memory->maxSize32())); } if (!preserveImportsAndExports) { From cbf899ad8b0ef484327a0ce0226ce9e40fe82e6f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 10 Jul 2026 14:09:57 -0700 Subject: [PATCH 2/2] fmt --- src/tools/fuzzing/fuzzing.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 8ed6e58e1a8..f2a8397e6e4 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -917,10 +917,9 @@ void TranslateToFuzzReader::finalizeMemory() { // To allow growth to work (which a testcase may assume), try to make the // maximum larger than the initial, some of the time. // TODO: scan the wasm for grow instructions? - memory->max = - std::min(Address(memory->initial + 1), - Address(memory->is64() ? memory->maxSize64() - : memory->maxSize32())); + memory->max = std::min( + Address(memory->initial + 1), + Address(memory->is64() ? memory->maxSize64() : memory->maxSize32())); } if (!preserveImportsAndExports) {