binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

RedundantSetElimination: Nondeterminism testcase

Open kateinoigakukun opened this issue 3 years ago • 2 comments

Fuzzer found issue on seed 14358101859341333857.

a.wasm.zip

$ wasm-opt a.wasm --rse --print --all-features > b1.wat
warning: no output file specified, not emitting output

$ wasm-opt a.wasm --rse --print --all-features > b2.wat
warning: no output file specified, not emitting output

$ diff b1.wat b2.wat
2741c2741
<                (local.set $35
---
>                (drop
3407c3407
<                     (drop
---
>                     (local.set $41

kateinoigakukun avatar Mar 02 '22 22:03 kateinoigakukun

I'm not able to reproduce this locally (even with setting cores to 1 or 100 etc.). But as a nondeterminism bug it probably just shows up on some machines.

Can you attach the full output wat files? Maybe seeing the entire context will help.

kripken avatar Mar 03 '22 00:03 kripken

Oh, I noticed that this is not reproducible on my other machine. OK, I attached wat files and fuzz_opt log.

b1_b2_wat.zip

/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-opt --print-features /Users/katei/.ghq/github.com/WebAssembly/binaryen/test/hello_world.wat --all-features
warning: no output file specified, not emitting output
POSSIBLE_FEATURE_OPTS: ['--disable-threads', '--disable-mutable-globals', '--disable-nontrapping-float-to-int', '--disable-simd', '--disable-bulk-memory', '--disable-sign-ext', '--disable-exception-handling', '--disable-tail-call', '--disable-reference-types', '--disable-multivalue', '--disable-gc', '--disable-memory64', '--disable-typed-function-references', '--disable-relaxed-simd']
checking a single given seed 14358101859341333857
- Perenially-important initial contents:
  lit/passes/optimize-instructions.wast
  passes/optimize-instructions_fuzz-exec.wast

- Recently added or modified initial contents (manually selected):
  lit/passes/once-reduction.wast
  passes/remove-unused-brs_enable-multivalue.wast
  lit/passes/optimize-instructions-bulk-memory.wast
  lit/passes/optimize-instructions-ignore-traps.wast
  lit/passes/optimize-instructions-gc.wast
  lit/passes/optimize-instructions-gc-iit.wast
  lit/passes/optimize-instructions-call_ref.wast
  lit/passes/inlining_splitting.wast
  heap-types.wast


ITERATION: 1 seed: 14358101859341333857 size: 74884 (mean: 74884.0, stddev: 0.0) speed: 21183.353535353537 iters/sec,  0.0 wasm_bytes/sec

randomized pass debug:
randomized feature opts: --all-features --disable-bulk-memory --disable-sign-ext --disable-memory64
randomized settings (NaNs, OOB, legalize): False False False
randomized opts: --rse --optimize-level=2

/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-opt input.dat -ttf -o a.wasm --denan --no-fuzz-oob --all-features --disable-bulk-memory --disable-sign-ext --disable-memory64
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
pre wasm size: 60645
/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-opt a.wasm --all-features --disable-bulk-memory --disable-sign-ext --disable-memory64 --print-features
warning: no output file specified, not emitting output
['--enable-threads', '--enable-mutable-globals', '--enable-nontrapping-float-to-int', '--enable-simd', '--enable-exception-handling', '--enable-tail-call', '--enable-reference-types', '--enable-multivalue', '--enable-gc', '--enable-typed-function-references', '--enable-relaxed-simd'] []
/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-opt a.wasm -o b.wasm --rse --optimize-level=2 --denan --no-fuzz-oob --enable-threads --enable-mutable-globals --enable-nontrapping-float-to-int --enable-simd --enable-exception-handling --enable-tail-call --enable-reference-types --enable-multivalue --enable-gc --enable-typed-function-references --enable-relaxed-simd
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
warning: cannot de-nan outside of function context
post wasm size: 77477
running testcase handler: CheckDeterminism
/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-opt a.wasm -o b1.wasm --rse --optimize-level=2 --enable-threads --enable-mutable-globals --enable-nontrapping-float-to-int --enable-simd --enable-exception-handling --enable-tail-call --enable-reference-types --enable-multivalue --enable-gc --enable-typed-function-references --enable-relaxed-simd
/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-opt a.wasm -o b2.wasm --rse --optimize-level=2 --enable-threads --enable-mutable-globals --enable-nontrapping-float-to-int --enable-simd --enable-exception-handling --enable-tail-call --enable-reference-types --enable-multivalue --enable-gc --enable-typed-function-references --enable-relaxed-simd
/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-dis b1.wasm -o b1.wat
/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-dis b2.wasm -o b2.wat
!
-----------------------------------------
Exception:
  File "./scripts/fuzz_opt.py", line 1300, in <module>
  File "./scripts/fuzz_opt.py", line 1103, in test_one
  File "./scripts/fuzz_opt.py", line 813, in handle_pair
  File "./scripts/fuzz_opt.py", line 395, in compare
-----------------------------------------
!
Output must be deterministic.
Diff:

--- expected

+++ actual

@@ -3233,7 +3233,7 @@

              )
              (drop
               (block $label$13 (result funcref)
-               (local.set $55
+               (drop
                 (ref.null func)
                )
                (drop

================================================================================
You found a bug! Please report it with

  seed: 14358101859341333857

and the exact version of Binaryen you found it on, plus the exact Python
version (hopefully deterministic random numbers will be identical).

You can run that testcase again with "fuzz_opt.py 14358101859341333857"

The initial wasm file used here is saved as /Users/katei/.ghq/github.com/WebAssembly/binaryen/out/test/original.wasm

You can reduce the testcase by running this now:

||||
vvvv


/Users/katei/.ghq/github.com/WebAssembly/build-relonly/bin/wasm-reduce /Users/katei/.ghq/github.com/WebAssembly/binaryen/out/test/original.wasm '--command=bash /Users/katei/.ghq/github.com/WebAssembly/binaryen/out/test/reduce.sh' -t /Users/katei/.ghq/github.com/WebAssembly/binaryen/out/test/t.wasm -w /Users/katei/.ghq/github.com/WebAssembly/binaryen/out/test/w.wasm


^^^^
||||

Make sure to verify by eye that the output says something like this:

At least one of the next two values should be 0:
  0
  1
The following value should be 1:
  1

(If it does not, then one possible issue is that the fuzzer fails to write a
valid binary. If so, you can print the output of the fuzzer's first command
(using -ttf / --translate-to-fuzz) in text form and run the reduction from that,
passing --text to the reducer.)

You can also read "/Users/katei/.ghq/github.com/WebAssembly/binaryen/out/test/reduce.sh" which has been filled out for you and includes
docs and suggestions.

After reduction, the reduced file will be in /Users/katei/.ghq/github.com/WebAssembly/binaryen/out/test/w.wasm
================================================================================

(finished running seed 14358101859341333857, see error above)

kateinoigakukun avatar Mar 03 '22 00:03 kateinoigakukun