From 98d2204d544e899ebfecd78bb90ec56bec8e70ec Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 5 Jun 2024 11:30:06 -0700 Subject: [PATCH] fix --- src/tools/fuzzing/fuzzing.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 57c7ec6b069..751625c0ab8 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -420,6 +420,13 @@ void TranslateToFuzzReader::setupGlobals() { // initializer. auto* init = makeTrivial(type); + if (type.isTuple() && !init->is()) { + // For now we disallow anything but tuple.make at the top level of tuple + // globals (see details in wasm-binary.cpp). In the future we may allow + // global.get or other things here. + init = makeConst(type); + assert(init->is()); + } if (!FindAll(init).list.empty()) { // When creating this initial value we ended up emitting a RefAs, which // means we had to stop in the middle of an overly-nested struct or array, @@ -428,13 +435,8 @@ void TranslateToFuzzReader::setupGlobals() { // validate in a global. Switch to something safe instead. type = getMVPType(); init = makeConst(type); - } else if (type.isTuple() && !init->is()) { - // For now we disallow anything but tuple.make at the top level of tuple - // globals (see details in wasm-binary.cpp). In the future we may allow - // global.get or other things here. - init = makeConst(type); - assert(init->is()); } + auto global = builder.makeGlobal( Names::getValidGlobalName(wasm, "global$"), type, init, mutability); useGlobalLater(wasm.addGlobal(std::move(global)));