diff options
Diffstat (limited to 'tests/fixtures/spec_testsuites/core')
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.108.wasm | bin | 0 -> 35 bytes | |||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.109.wasm | bin | 0 -> 35 bytes | |||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.110.wasm | bin | 0 -> 35 bytes | |||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.111.wasm | bin | 0 -> 35 bytes | |||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.112.wasm | bin | 0 -> 35 bytes | |||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.113.wasm | bin | 0 -> 35 bytes | |||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.json | 8 | ||||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/align.wast | 117 | ||||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/elem.wast | 10 | ||||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/memory.34.wasm | bin | 0 -> 121 bytes | |||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/memory.json | 11 | ||||
| -rw-r--r-- | tests/fixtures/spec_testsuites/core/memory.wast | 65 |
12 files changed, 184 insertions, 27 deletions
diff --git a/tests/fixtures/spec_testsuites/core/align.108.wasm b/tests/fixtures/spec_testsuites/core/align.108.wasm Binary files differnew file mode 100644 index 0000000..a9f8923 --- /dev/null +++ b/tests/fixtures/spec_testsuites/core/align.108.wasm diff --git a/tests/fixtures/spec_testsuites/core/align.109.wasm b/tests/fixtures/spec_testsuites/core/align.109.wasm Binary files differnew file mode 100644 index 0000000..b1b383a --- /dev/null +++ b/tests/fixtures/spec_testsuites/core/align.109.wasm diff --git a/tests/fixtures/spec_testsuites/core/align.110.wasm b/tests/fixtures/spec_testsuites/core/align.110.wasm Binary files differnew file mode 100644 index 0000000..02b2b33 --- /dev/null +++ b/tests/fixtures/spec_testsuites/core/align.110.wasm diff --git a/tests/fixtures/spec_testsuites/core/align.111.wasm b/tests/fixtures/spec_testsuites/core/align.111.wasm Binary files differnew file mode 100644 index 0000000..0889153 --- /dev/null +++ b/tests/fixtures/spec_testsuites/core/align.111.wasm diff --git a/tests/fixtures/spec_testsuites/core/align.112.wasm b/tests/fixtures/spec_testsuites/core/align.112.wasm Binary files differnew file mode 100644 index 0000000..2464ab1 --- /dev/null +++ b/tests/fixtures/spec_testsuites/core/align.112.wasm diff --git a/tests/fixtures/spec_testsuites/core/align.113.wasm b/tests/fixtures/spec_testsuites/core/align.113.wasm Binary files differnew file mode 100644 index 0000000..3b417ec --- /dev/null +++ b/tests/fixtures/spec_testsuites/core/align.113.wasm diff --git a/tests/fixtures/spec_testsuites/core/align.json b/tests/fixtures/spec_testsuites/core/align.json index 5dd722e..c44b51a 100644 --- a/tests/fixtures/spec_testsuites/core/align.json +++ b/tests/fixtures/spec_testsuites/core/align.json @@ -155,4 +155,10 @@ {"type": "assert_return", "line": 850, "action": {"type": "invoke", "field": "i64_align_switch", "args": [{"type": "i32", "value": "6"}, {"type": "i32", "value": "8"}]}, "expected": [{"type": "i64", "value": "10"}]}, {"type": "module", "line": 854, "filename": "align.107.wasm"}, {"type": "assert_trap", "line": 864, "action": {"type": "invoke", "field": "store", "args": [{"type": "i32", "value": "65532"}, {"type": "i64", "value": "18446744073709551615"}]}, "text": "out of bounds memory access", "expected": []}, - {"type": "assert_return", "line": 866, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "65532"}]}, "expected": [{"type": "i32", "value": "0"}]}]} + {"type": "assert_return", "line": 866, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "65532"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_invalid", "line": 873, "filename": "align.108.wasm", "text": "alignment must not be larger than natural", "module_type": "binary"}, + {"type": "assert_malformed", "line": 892, "filename": "align.109.wasm", "text": "malformed memop flags", "module_type": "binary"}, + {"type": "assert_malformed", "line": 911, "filename": "align.110.wasm", "text": "malformed memop flags", "module_type": "binary"}, + {"type": "assert_malformed", "line": 930, "filename": "align.111.wasm", "text": "malformed memop flags", "module_type": "binary"}, + {"type": "assert_malformed", "line": 949, "filename": "align.112.wasm", "text": "malformed memop flags", "module_type": "binary"}, + {"type": "assert_malformed", "line": 968, "filename": "align.113.wasm", "text": "malformed memop flags", "module_type": "binary"}]} diff --git a/tests/fixtures/spec_testsuites/core/align.wast b/tests/fixtures/spec_testsuites/core/align.wast index 9306464..7753df8 100644 --- a/tests/fixtures/spec_testsuites/core/align.wast +++ b/tests/fixtures/spec_testsuites/core/align.wast @@ -864,3 +864,120 @@ (assert_trap (invoke "store" (i32.const 65532) (i64.const -1)) "out of bounds memory access") ;; No memory was changed (assert_return (invoke "load" (i32.const 65532)) (i32.const 0)) + +;; Test invalid alignment values that may cause overflow when parsed. +;; These use the binary format, because it stores alignment as a base-2 exponent. + +;; Signed 32-bit overflow +(assert_invalid + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section: 1 type + "\03\02\01\00" ;; Function section: 1 function + "\05\03\01\00\01" ;; Memory section: 1 memory + "\0a\0a\01" ;; Code section: 1 function + + ;; function 0 + "\08\00" + "\41\00" ;; i32.const 0 + "\28\1f\00" ;; i32.load offset=0 align=2**31 + "\1a" ;; drop + "\0b" ;; end + ) + "alignment must not be larger than natural" +) + +;; Unsigned 32-bit overflow +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section: 1 type + "\03\02\01\00" ;; Function section: 1 function + "\05\03\01\00\01" ;; Memory section: 1 memory + "\0a\0a\01" ;; Code section: 1 function + + ;; function 0 + "\08\00" + "\41\00" ;; i32.const 0 + "\28\20\00" ;; i32.load offset=0 align=2**32 + "\1a" ;; drop + "\0b" ;; end + ) + "malformed memop flags" +) + +;; 32-bit out of range +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section: 1 type + "\03\02\01\00" ;; Function section: 1 function + "\05\03\01\00\01" ;; Memory section: 1 memory + "\0a\0a\01" ;; Code section: 1 function + + ;; function 0 + "\08\00" + "\41\00" ;; i32.const 0 + "\28\21\00" ;; i32.load offset=0 align=2**33 + "\1a" ;; drop + "\0b" ;; end + ) + "malformed memop flags" +) + +;; Signed 64-bit overflow +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section: 1 type + "\03\02\01\00" ;; Function section: 1 function + "\05\03\01\00\01" ;; Memory section: 1 memory + "\0a\0a\01" ;; Code section: 1 function + + ;; function 0 + "\08\00" + "\41\00" ;; i32.const 0 + "\28\3f\00" ;; i32.load offset=0 align=2**63 + "\1a" ;; drop + "\0b" ;; end + ) + "malformed memop flags" +) + +;; Unsigned 64-bit overflow +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section: 1 type + "\03\02\01\00" ;; Function section: 1 function + "\05\03\01\00\01" ;; Memory section: 1 memory + "\0a\0a\01" ;; Code section: 1 function + + ;; function 0 + "\08\00" + "\41\00" ;; i32.const 0 + "\28\40\00" ;; i32.load offset=0 align=2**64 + "\1a" ;; drop + "\0b" ;; end + ) + "malformed memop flags" +) + +;; 64-bit out of range +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section: 1 type + "\03\02\01\00" ;; Function section: 1 function + "\05\03\01\00\01" ;; Memory section: 1 memory + "\0a\0a\01" ;; Code section: 1 function + + ;; function 0 + "\08\00" + "\41\00" ;; i32.const 0 + "\28\41\00" ;; i32.load offset=0 align=2**65 + "\1a" ;; drop + "\0b" ;; end + ) + "malformed memop flags" +) diff --git a/tests/fixtures/spec_testsuites/core/elem.wast b/tests/fixtures/spec_testsuites/core/elem.wast index 33b3f67..68a244b 100644 --- a/tests/fixtures/spec_testsuites/core/elem.wast +++ b/tests/fixtures/spec_testsuites/core/elem.wast @@ -644,11 +644,11 @@ ;; Initializing a table with an externref-type element segment (module $m - (table $t (export "table") 2 externref) - (func (export "get") (param $i i32) (result externref) - (table.get $t (local.get $i))) - (func (export "set") (param $i i32) (param $x externref) - (table.set $t (local.get $i) (local.get $x)))) + (table $t (export "table") 2 externref) + (func (export "get") (param $i i32) (result externref) + (table.get $t (local.get $i))) + (func (export "set") (param $i i32) (param $x externref) + (table.set $t (local.get $i) (local.get $x)))) (register "exporter" $m) diff --git a/tests/fixtures/spec_testsuites/core/memory.34.wasm b/tests/fixtures/spec_testsuites/core/memory.34.wasm Binary files differnew file mode 100644 index 0000000..d55916d --- /dev/null +++ b/tests/fixtures/spec_testsuites/core/memory.34.wasm diff --git a/tests/fixtures/spec_testsuites/core/memory.json b/tests/fixtures/spec_testsuites/core/memory.json index 03689fc..5b191ff 100644 --- a/tests/fixtures/spec_testsuites/core/memory.json +++ b/tests/fixtures/spec_testsuites/core/memory.json @@ -78,4 +78,13 @@ {"type": "assert_return", "line": 227, "action": {"type": "invoke", "field": "i64_load32_u", "args": [{"type": "i64", "value": "3771275841602506223"}]}, "expected": [{"type": "i64", "value": "2562379247"}]}, {"type": "assert_malformed", "line": 231, "filename": "memory.31.wat", "text": "duplicate memory", "module_type": "text"}, {"type": "assert_malformed", "line": 235, "filename": "memory.32.wat", "text": "duplicate memory", "module_type": "text"}, - {"type": "assert_malformed", "line": 239, "filename": "memory.33.wat", "text": "duplicate memory", "module_type": "text"}]} + {"type": "assert_malformed", "line": 239, "filename": "memory.33.wat", "text": "duplicate memory", "module_type": "text"}, + {"type": "module", "line": 246, "filename": "memory.34.wasm"}, + {"type": "assert_return", "line": 260, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_return", "line": 261, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "10000"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_return", "line": 262, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "20000"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_return", "line": 263, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "30000"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_return", "line": 264, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "40000"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_return", "line": 265, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "50000"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_return", "line": 266, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "60000"}]}, "expected": [{"type": "i32", "value": "0"}]}, + {"type": "assert_return", "line": 267, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "65535"}]}, "expected": [{"type": "i32", "value": "0"}]}]} diff --git a/tests/fixtures/spec_testsuites/core/memory.wast b/tests/fixtures/spec_testsuites/core/memory.wast index 497b69f..baebde3 100644 --- a/tests/fixtures/spec_testsuites/core/memory.wast +++ b/tests/fixtures/spec_testsuites/core/memory.wast @@ -136,44 +136,44 @@ ;; Sign and zero extending memory loads (func (export "i32_load8_s") (param $i i32) (result i32) - (i32.store8 (i32.const 8) (local.get $i)) - (i32.load8_s (i32.const 8)) + (i32.store8 (i32.const 8) (local.get $i)) + (i32.load8_s (i32.const 8)) ) (func (export "i32_load8_u") (param $i i32) (result i32) - (i32.store8 (i32.const 8) (local.get $i)) - (i32.load8_u (i32.const 8)) + (i32.store8 (i32.const 8) (local.get $i)) + (i32.load8_u (i32.const 8)) ) (func (export "i32_load16_s") (param $i i32) (result i32) - (i32.store16 (i32.const 8) (local.get $i)) - (i32.load16_s (i32.const 8)) + (i32.store16 (i32.const 8) (local.get $i)) + (i32.load16_s (i32.const 8)) ) (func (export "i32_load16_u") (param $i i32) (result i32) - (i32.store16 (i32.const 8) (local.get $i)) - (i32.load16_u (i32.const 8)) + (i32.store16 (i32.const 8) (local.get $i)) + (i32.load16_u (i32.const 8)) ) (func (export "i64_load8_s") (param $i i64) (result i64) - (i64.store8 (i32.const 8) (local.get $i)) - (i64.load8_s (i32.const 8)) + (i64.store8 (i32.const 8) (local.get $i)) + (i64.load8_s (i32.const 8)) ) (func (export "i64_load8_u") (param $i i64) (result i64) - (i64.store8 (i32.const 8) (local.get $i)) - (i64.load8_u (i32.const 8)) + (i64.store8 (i32.const 8) (local.get $i)) + (i64.load8_u (i32.const 8)) ) (func (export "i64_load16_s") (param $i i64) (result i64) - (i64.store16 (i32.const 8) (local.get $i)) - (i64.load16_s (i32.const 8)) + (i64.store16 (i32.const 8) (local.get $i)) + (i64.load16_s (i32.const 8)) ) (func (export "i64_load16_u") (param $i i64) (result i64) - (i64.store16 (i32.const 8) (local.get $i)) - (i64.load16_u (i32.const 8)) + (i64.store16 (i32.const 8) (local.get $i)) + (i64.load16_u (i32.const 8)) ) (func (export "i64_load32_s") (param $i i64) (result i64) - (i64.store32 (i32.const 8) (local.get $i)) - (i64.load32_s (i32.const 8)) + (i64.store32 (i32.const 8) (local.get $i)) + (i64.load32_s (i32.const 8)) ) (func (export "i64_load32_u") (param $i i64) (result i64) - (i64.store32 (i32.const 8) (local.get $i)) - (i64.load32_u (i32.const 8)) + (i64.store32 (i32.const 8) (local.get $i)) + (i64.load32_u (i32.const 8)) ) ) @@ -240,3 +240,28 @@ "(import \"\" \"\" (memory $foo 1))" "(import \"\" \"\" (memory $foo 1))") "duplicate memory") + +;; Test that exporting random globals does not change a memory's semantics. + +(module + (memory (export "memory") 1 1) + + ;; These should not change the behavior of memory accesses. + (global (export "__data_end") i32 (i32.const 10000)) + (global (export "__stack_top") i32 (i32.const 10000)) + (global (export "__heap_base") i32 (i32.const 10000)) + + (func (export "load") (param i32) (result i32) + (i32.load8_u (local.get 0)) + ) +) + +;; None of these memory accesses should trap. +(assert_return (invoke "load" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "load" (i32.const 10000)) (i32.const 0)) +(assert_return (invoke "load" (i32.const 20000)) (i32.const 0)) +(assert_return (invoke "load" (i32.const 30000)) (i32.const 0)) +(assert_return (invoke "load" (i32.const 40000)) (i32.const 0)) +(assert_return (invoke "load" (i32.const 50000)) (i32.const 0)) +(assert_return (invoke "load" (i32.const 60000)) (i32.const 0)) +(assert_return (invoke "load" (i32.const 65535)) (i32.const 0)) |
