From d1ac3dd2d9c18fdb0e6a52d07429d2180e2ce39c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 23 Oct 2025 12:57:16 -0700 Subject: [PATCH 1/2] work --- src/tools/fuzzing/fuzzing.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index dca25fff59b..0d30a0d1730 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -450,6 +450,17 @@ void TranslateToFuzzReader::setupHeapTypes() { // initial content we began with. auto possibleHeapTypes = ModuleUtils::collectHeapTypes(wasm); + // Use heap types from an imported module, if present. + if (importedModule) { + auto importedHeapTypes = ModuleUtils::collectHeapTypes(*importedModule); + auto rate = upTo(101); + for (auto type : importedHeapTypes) { + if (upTo(100) < rate) { + possibleHeapTypes.push_back(type); + } + } + } + // Filter away uninhabitable heap types, that is, heap types that we cannot // construct, like a type with a non-nullable reference to itself. interestingHeapTypes = HeapTypeGenerator::getInhabitable(possibleHeapTypes); @@ -1213,9 +1224,9 @@ void TranslateToFuzzReader::useImportedFunctions() { } // Add some of the module's exported functions as imports, at a random rate. - auto rate = upTo(100); + auto rate = upTo(101); for (auto& exp : importedModule->exports) { - if (exp->kind != ExternalKind::Function || upTo(100) > rate) { + if (exp->kind != ExternalKind::Function || upTo(100) >= rate) { continue; } @@ -1243,9 +1254,9 @@ void TranslateToFuzzReader::useImportedGlobals() { } // Add some of the module's exported globals as imports, at a random rate. - auto rate = upTo(100); + auto rate = upTo(101); for (auto& exp : importedModule->exports) { - if (exp->kind != ExternalKind::Global || upTo(100) > rate) { + if (exp->kind != ExternalKind::Global || upTo(100) >= rate) { continue; } From 6ce4bce51513e4e2f559bbb26bb1b8ccd70a5bd6 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 23 Oct 2025 13:19:44 -0700 Subject: [PATCH 2/2] work --- src/tools/fuzzing/fuzzing.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 0d30a0d1730..8702d7f2dca 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -453,9 +453,9 @@ void TranslateToFuzzReader::setupHeapTypes() { // Use heap types from an imported module, if present. if (importedModule) { auto importedHeapTypes = ModuleUtils::collectHeapTypes(*importedModule); - auto rate = upTo(101); + auto rate = upTo(11); for (auto type : importedHeapTypes) { - if (upTo(100) < rate) { + if (upTo(10) < rate) { possibleHeapTypes.push_back(type); } } @@ -1224,9 +1224,9 @@ void TranslateToFuzzReader::useImportedFunctions() { } // Add some of the module's exported functions as imports, at a random rate. - auto rate = upTo(101); + auto rate = upTo(11); for (auto& exp : importedModule->exports) { - if (exp->kind != ExternalKind::Function || upTo(100) >= rate) { + if (exp->kind != ExternalKind::Function || upTo(10) >= rate) { continue; } @@ -1254,9 +1254,9 @@ void TranslateToFuzzReader::useImportedGlobals() { } // Add some of the module's exported globals as imports, at a random rate. - auto rate = upTo(101); + auto rate = upTo(11); for (auto& exp : importedModule->exports) { - if (exp->kind != ExternalKind::Global || upTo(100) >= rate) { + if (exp->kind != ExternalKind::Global || upTo(10) >= rate) { continue; }