From 84b41cfc3ce7cb1eb2357731bef5e0bf898e8d96 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 14 May 2026 15:01:54 -0700 Subject: [PATCH] Supply fuzz imports to second modules as well Update execution-results.h to supply standard fuzzing imports, including imported externref globals materialized on demand, to second modules. This matches the behavior of fuzz_shell.js, which already makes these imports available to both modules. --- src/tools/execution-results.h | 5 ++++- test/lit/exec/fuzz-exec-second-import.wast | 16 ++++++++++++++++ .../lit/exec/fuzz-exec-second-import.wast.second | 7 +++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/lit/exec/fuzz-exec-second-import.wast create mode 100644 test/lit/exec/fuzz-exec-second-import.wast.second diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index 09f7657ee96..903f866d59d 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -470,7 +470,10 @@ struct ExecutionResults { secondInterface = std::make_unique( loggings, *second, linkedInstances); secondInstance = std::make_shared( - *second, secondInterface.get(), linkedInstances); + *second, + secondInterface.get(), + linkedInstances, + std::make_shared(linkedInstances)); instantiate(*secondInstance, *secondInterface); } diff --git a/test/lit/exec/fuzz-exec-second-import.wast b/test/lit/exec/fuzz-exec-second-import.wast new file mode 100644 index 00000000000..765b63e8505 --- /dev/null +++ b/test/lit/exec/fuzz-exec-second-import.wast @@ -0,0 +1,16 @@ +;; RUN: wasm-opt %s -all --fuzz-exec-before --fuzz-exec-second=%s.second -q -o /dev/null 2>&1 | filecheck %s + +;; Check that imported externref globals work in second modules as well. + +(module + (import "__fuzz_import" "extern$" (global $gimport$0 externref)) + + (func (export "check") (result i32) + (ref.is_null (global.get $gimport$0)) + ) +) + +;; CHECK: [fuzz-exec] export check +;; CHECK-NEXT: [fuzz-exec] note result: check => 0 +;; CHECK: [fuzz-exec] export check_second +;; CHECK-NEXT: [fuzz-exec] note result: check_second => 0 diff --git a/test/lit/exec/fuzz-exec-second-import.wast.second b/test/lit/exec/fuzz-exec-second-import.wast.second new file mode 100644 index 00000000000..0b3e09d59c0 --- /dev/null +++ b/test/lit/exec/fuzz-exec-second-import.wast.second @@ -0,0 +1,7 @@ +(module + (import "__fuzz_import" "extern$" (global $gimport$0 externref)) + + (func (export "check_second") (result i32) + (ref.is_null (global.get $gimport$0)) + ) +)