Skip to content

Commit d45188d

Browse files
authored
Add more address overflow tests (#1188)
There are already tests for effective address overflow, but those have a large value baked into the offset. These tests all use `1` as the immediate offset, and use `-1` for the address on the stack, which may be compiled differently.
1 parent cbe59e8 commit d45188d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/core/address.wast

+21
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@
191191
(assert_return (invoke "32_good4" (i32.const 65508)) (i32.const 0))
192192
(assert_trap (invoke "32_good5" (i32.const 65508)) "out of bounds memory access")
193193

194+
(assert_trap (invoke "8u_good3" (i32.const -1)) "out of bounds memory access")
195+
(assert_trap (invoke "8s_good3" (i32.const -1)) "out of bounds memory access")
196+
(assert_trap (invoke "16u_good3" (i32.const -1)) "out of bounds memory access")
197+
(assert_trap (invoke "16s_good3" (i32.const -1)) "out of bounds memory access")
198+
(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")
199+
(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")
200+
194201
(assert_trap (invoke "8u_bad" (i32.const 0)) "out of bounds memory access")
195202
(assert_trap (invoke "8s_bad" (i32.const 0)) "out of bounds memory access")
196203
(assert_trap (invoke "16u_bad" (i32.const 0)) "out of bounds memory access")
@@ -478,6 +485,14 @@
478485
(assert_return (invoke "64_good4" (i32.const 65504)) (i64.const 0))
479486
(assert_trap (invoke "64_good5" (i32.const 65504)) "out of bounds memory access")
480487

488+
(assert_trap (invoke "8u_good3" (i32.const -1)) "out of bounds memory access")
489+
(assert_trap (invoke "8s_good3" (i32.const -1)) "out of bounds memory access")
490+
(assert_trap (invoke "16u_good3" (i32.const -1)) "out of bounds memory access")
491+
(assert_trap (invoke "16s_good3" (i32.const -1)) "out of bounds memory access")
492+
(assert_trap (invoke "32u_good3" (i32.const -1)) "out of bounds memory access")
493+
(assert_trap (invoke "32s_good3" (i32.const -1)) "out of bounds memory access")
494+
(assert_trap (invoke "64_good3" (i32.const -1)) "out of bounds memory access")
495+
481496
(assert_trap (invoke "8u_bad" (i32.const 0)) "out of bounds memory access")
482497
(assert_trap (invoke "8s_bad" (i32.const 0)) "out of bounds memory access")
483498
(assert_trap (invoke "16u_bad" (i32.const 0)) "out of bounds memory access")
@@ -538,6 +553,9 @@
538553
(assert_return (invoke "32_good4" (i32.const 65525)) (f32.const 0.0))
539554
(assert_trap (invoke "32_good5" (i32.const 65525)) "out of bounds memory access")
540555

556+
(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")
557+
(assert_trap (invoke "32_good3" (i32.const -1)) "out of bounds memory access")
558+
541559
(assert_trap (invoke "32_bad" (i32.const 0)) "out of bounds memory access")
542560
(assert_trap (invoke "32_bad" (i32.const 1)) "out of bounds memory access")
543561

@@ -585,5 +603,8 @@
585603
(assert_return (invoke "64_good4" (i32.const 65511)) (f64.const 0.0))
586604
(assert_trap (invoke "64_good5" (i32.const 65511)) "out of bounds memory access")
587605

606+
(assert_trap (invoke "64_good3" (i32.const -1)) "out of bounds memory access")
607+
(assert_trap (invoke "64_good3" (i32.const -1)) "out of bounds memory access")
608+
588609
(assert_trap (invoke "64_bad" (i32.const 0)) "out of bounds memory access")
589610
(assert_trap (invoke "64_bad" (i32.const 1)) "out of bounds memory access")

0 commit comments

Comments
 (0)