Skip to content

Commit a8ccf99

Browse files
Disable relaxed atomics for v8 tests in the fuzzer (#8199)
Followup to #8169. Fixes the fuzzer which currently generates code with --enable-relaxed-atomics which isn't supported in v8. To test, I ran the fuzzer successfully for ~20 minutes locally. Part of #8165. In the future, we'll also add fuzzing support for relaxed atomics by generating acqrel instructions.
1 parent abf9693 commit a8ccf99

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

scripts/bundle_clusterfuzz.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
'--disable-fp16',
110110
'--disable-strings',
111111
'--disable-stack-switching',
112+
'--disable-relaxed-atomics',
112113
]
113114

114115
with tarfile.open(output_file, "w:gz") as tar:

scripts/clusterfuzz/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
'--disable-fp16',
9494
'--disable-strings',
9595
'--disable-stack-switching',
96+
'--disable-relaxed-atomics',
9697
]
9798

9899

scripts/fuzz_opt.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262

6363
CLOSED_WORLD_FLAG = '--closed-world'
6464

65+
# V8 does not support shared memories when running with
66+
# shared-everything enabled, so do not fuzz shared-everything
67+
# for now. The remaining features are not yet implemented in v8.
68+
DISALLOWED_FEATURES_IN_V8 = ['shared-everything', 'strings', 'stack-switching', 'relaxed-atomics']
69+
6570

6671
# utilities
6772

@@ -143,19 +148,15 @@ def randomize_feature_opts():
143148
if possible in IMPLIED_FEATURE_OPTS:
144149
FEATURE_OPTS.extend(IMPLIED_FEATURE_OPTS[possible])
145150
elif random.random() < 0.9:
146-
# 2/3 of the remaining 90% use them all. This is useful to maximize
151+
# 90% of the remaining (2/3 * 0.9) use them all (0.54 probability). This is useful to maximize
147152
# coverage, as enabling more features enables more optimizations and
148153
# code paths, and also allows all initial contents to run.
149154

150-
# The shared-everything feature is new and we want to fuzz it, but it
151-
# also currently disables fuzzing V8, so disable it most of the time.
152-
# Same with strings. Relaxed SIMD's nondeterminism disables much but not
153-
# all of our V8 fuzzing, so avoid it too. Stack Switching, as well, is
154-
# not yet ready in V8.
155-
FEATURE_OPTS.append('--disable-shared-everything')
156-
FEATURE_OPTS.append('--disable-strings')
155+
# Disable features not allowed in V8 to increase V8 fuzzing.
156+
FEATURE_OPTS.extend(f'--disable-{feature}' for feature in DISALLOWED_FEATURES_IN_V8)
157+
# Relaxed SIMD's nondeterminism disables much but not
158+
# all of our V8 fuzzing, so avoid it.
157159
FEATURE_OPTS.append('--disable-relaxed-simd')
158-
FEATURE_OPTS.append('--disable-stack-switching')
159160

160161
print('randomized feature opts:', '\n ' + '\n '.join(FEATURE_OPTS))
161162

@@ -824,11 +825,7 @@ def run(self, wasm, extra_d8_flags=[]):
824825
return run_vm([shared.V8, get_fuzz_shell_js()] + shared.V8_OPTS + get_v8_extra_flags() + extra_d8_flags + ['--', wasm])
825826

826827
def can_run(self, wasm):
827-
# V8 does not support shared memories when running with
828-
# shared-everything enabled, so do not fuzz shared-everything
829-
# for now. It also does not yet support strings, nor stack
830-
# switching
831-
return all_disallowed(['shared-everything', 'strings', 'stack-switching'])
828+
return all_disallowed(DISALLOWED_FEATURES_IN_V8)
832829

833830
def can_compare_to_self(self):
834831
# With nans, VM differences can confuse us, so only very simple VMs
@@ -886,7 +883,7 @@ def can_run(self, wasm):
886883
if random.random() < 0.5:
887884
return False
888885
# wasm2c doesn't support most features
889-
return all_disallowed(['exception-handling', 'simd', 'threads', 'bulk-memory', 'nontrapping-float-to-int', 'tail-call', 'sign-ext', 'reference-types', 'multivalue', 'gc', 'custom-descriptors'])
886+
return all_disallowed(['exception-handling', 'simd', 'threads', 'bulk-memory', 'nontrapping-float-to-int', 'tail-call', 'sign-ext', 'reference-types', 'multivalue', 'gc', 'custom-descriptors', 'relaxed-atomics'])
890887

891888
def run(self, wasm):
892889
run([in_bin('wasm-opt'), wasm, '--emit-wasm2c-wrapper=main.c'] + FEATURE_OPTS)
@@ -1187,7 +1184,7 @@ def can_run_on_wasm(self, wasm):
11871184
# implement wasm suspending using JS async/await.
11881185
if JSPI:
11891186
return False
1190-
return all_disallowed(['exception-handling', 'simd', 'threads', 'bulk-memory', 'nontrapping-float-to-int', 'tail-call', 'sign-ext', 'reference-types', 'multivalue', 'gc', 'multimemory', 'memory64', 'custom-descriptors'])
1187+
return all_disallowed(['exception-handling', 'simd', 'threads', 'bulk-memory', 'nontrapping-float-to-int', 'tail-call', 'sign-ext', 'reference-types', 'multivalue', 'gc', 'multimemory', 'memory64', 'custom-descriptors', 'relaxed-atomics'])
11911188

11921189

11931190
# Returns the wat for a wasm file. If it is already wat, it just returns that
@@ -1655,7 +1652,7 @@ def can_run_on_wasm(self, wasm):
16551652
return False
16561653

16571654
# see D8.can_run
1658-
return all_disallowed(['shared-everything', 'strings', 'stack-switching'])
1655+
return all_disallowed(DISALLOWED_FEATURES_IN_V8)
16591656

16601657

16611658
# Check that the text format round-trips without error.
@@ -1944,7 +1941,7 @@ def handle(self, wasm):
19441941
# (as optimizations can lead to different outputs), and we must
19451942
# disallow some features.
19461943
# TODO: relax some of these
1947-
if NANS or not all_disallowed(['shared-everything', 'strings', 'stack-switching']):
1944+
if NANS or not all_disallowed(DISALLOWED_FEATURES_IN_V8):
19481945
return
19491946

19501947
output = run_d8_wasm(wasm, args=[second_wasm])

0 commit comments

Comments
 (0)