diff options
author | Alon Zakai <azakai@google.com> | 2020-11-13 11:14:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 11:14:44 -0800 |
commit | 0f49b56029f93c1b54736ed2473d23f457d46894 (patch) | |
tree | 50e6e57a475971827137a0f4aacd27ae257e9489 /test | |
parent | 262bd62777fcde6b930d520e61457699dbb9901e (diff) | |
download | binaryen-0f49b56029f93c1b54736ed2473d23f457d46894.tar.gz binaryen-0f49b56029f93c1b54736ed2473d23f457d46894.tar.bz2 binaryen-0f49b56029f93c1b54736ed2473d23f457d46894.zip |
Fix a hashing regression from #3332 (#3349)
We used to check if a load's sign matters before hashing it. If the load does
not extend, then the sign doesn't matter, and we ignored the value there. It
turns out that value could be garbage, as we didn't assign it in the binary
reader, if it wasn't relevant. In the rewrite this was missed, and actually it's
not really possible to do, since we have just a macro for the field, but not the
object it is on - which there may be more than one.
To fix this, just always assign the field. This is simpler anyhow, and avoids
confusion not just here but probably when debugging.
The testcase here is reduced from the fuzzer, and is not a 100% guarantee
to catch a read of uninitialized memory, but it can't hurt, and with ASan it
may be pretty consistent.
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/roundtrip_signed.bin.txt | 26 | ||||
-rw-r--r-- | test/passes/roundtrip_signed.passes | 1 | ||||
-rw-r--r-- | test/passes/roundtrip_signed.wasm | bin | 0 -> 151 bytes |
3 files changed, 27 insertions, 0 deletions
diff --git a/test/passes/roundtrip_signed.bin.txt b/test/passes/roundtrip_signed.bin.txt new file mode 100644 index 000000000..0406da34a --- /dev/null +++ b/test/passes/roundtrip_signed.bin.txt @@ -0,0 +1,26 @@ +(module + (type $none_=>_none (func)) + (memory $0 16 17) + (global $global$0 (mut i32) (i32.const 10)) + (export "as-br_table-index" (func $0)) + (export "as-local.set-value" (func $0)) + (func $0 + (if + (i32.eqz + (global.get $global$0) + ) + (return) + ) + (global.set $global$0 + (i32.sub + (global.get $global$0) + (i32.const 1) + ) + ) + (drop + (i32.load + (i32.const 0) + ) + ) + ) +) diff --git a/test/passes/roundtrip_signed.passes b/test/passes/roundtrip_signed.passes new file mode 100644 index 000000000..2417a0536 --- /dev/null +++ b/test/passes/roundtrip_signed.passes @@ -0,0 +1 @@ +remove-unused-module-elements_roundtrip_vacuum_remove-unused-brs_merge-blocks_vacuum_duplicate-function-elimination diff --git a/test/passes/roundtrip_signed.wasm b/test/passes/roundtrip_signed.wasm Binary files differnew file mode 100644 index 000000000..46ec0b98c --- /dev/null +++ b/test/passes/roundtrip_signed.wasm |