From de287f9582e4d8761c80ce4d527f098f3301ed60 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 23 Oct 2026 18:28:03 -0700 Subject: [PATCH] [Fuzzing] Fix feature checks in get_random_opts In test_one(), get_random_opts() was called before update_feature_opts('a.wasm') converted FEATURE_OPTS from '--all-features --disable-*' into explicit '--enable-*' flags, so get_random_opts() never saw the active '--enable-*' flags when selecting passes for test_one(). In addition, get_random_opts() checked "'--gc' not in FEATURE_OPTS" instead of "'--enable-gc' in FEATURE_OPTS", which was always true and caused '--flatten', '-O4', '--rereloop', and '--dfo' to be skipped on every call. Move get_random_opts() after update_feature_opts('a.wasm') and check for '--enable-gc' in FEATURE_OPTS. --- scripts/fuzz_opt.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index c97d9cb252e..4ec35d47138 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -2593,10 +2593,6 @@ def test_one(random_input, given_wasm): randomize_fuzz_settings() pick_initial_contents() - opts = get_random_opts() - print('randomized opts:', '\n ' + '\n '.join(opts)) - print() - if given_wasm: # We are given a wasm file to operate on. By default we modify it in the # usual ways, like running DeNAN on it, which is important in many cases @@ -2630,6 +2626,10 @@ def test_one(random_input, given_wasm): print('pre wasm size:', wasm_size) update_feature_opts('a.wasm') + opts = get_random_opts() + print('randomized opts:', '\n ' + '\n '.join(opts)) + print() + # create a second (optimized) wasm for handlers that want to look at pairs. generate_command = [in_bin('wasm-opt'), abspath('a.wasm'), '-o', abspath('b.wasm')] + opts + FUZZ_OPTS + FEATURE_OPTS if PRINT_WATS: @@ -2825,7 +2825,7 @@ def get_random_opts(): if '--enable-exception-handling' in FEATURE_OPTS: print('avoiding --flatten due to exception-handling not supporting it (requires blocks with results)') continue - if '--gc' not in FEATURE_OPTS: + if '--enable-gc' in FEATURE_OPTS: print('avoiding --flatten due to GC not supporting it (spilling of non-nullable locals)') continue if INITIAL_CONTENTS and os.path.getsize(INITIAL_CONTENTS) > 2000: