Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit bbf08e4

Browse files
authored
[test] Add more address overflow tests (#229)
Echo to github.com/WebAssembly/spec/pull/1188, add more address overflow tests with offset set to `1` and address set to `-1`, which may be complied differently.
1 parent f692ef0 commit bbf08e4

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

test/core/simd/simd_address.wast

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
(v128.store offset=65520 align=1 (i32.const 0) (v128.const i32x4 0 1 2 3))
4646
(v128.load offset=65520 (i32.const 0))
4747
)
48+
(func (export "store_data_6") (param $i i32)
49+
(v128.store offset=1 align=1 (local.get $i) (v128.const i32x4 0 1 2 3))
50+
)
4851
)
4952

5053
(assert_return (invoke "load_data_1" (i32.const 0)) (v128.const i32x4 0x03020100 0x07060504 0x11100908 0x15141312))
@@ -83,6 +86,7 @@
8386
(assert_return (invoke "load_data_4" (i32.const 65505)) (v128.const i8x16 0x18 0x19 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x30 0x31 0x00 0x00))
8487
(assert_return (invoke "load_data_5" (i32.const 65505)) (v128.const i8x16 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00))
8588

89+
(assert_trap (invoke "load_data_3" (i32.const -1)) "out of bounds memory access")
8690
(assert_trap (invoke "load_data_5" (i32.const 65506)) "out of bounds memory access")
8791

8892
(assert_return (invoke "store_data_0") (v128.const f32x4 0 1 2 3))
@@ -92,6 +96,8 @@
9296
(assert_return (invoke "store_data_4") (v128.const i32x4 0 1 2 3))
9397
(assert_return (invoke "store_data_5") (v128.const i32x4 0 1 2 3))
9498

99+
(assert_trap (invoke "store_data_6" (i32.const -1)) "out of bounds memory access")
100+
(assert_trap (invoke "store_data_6" (i32.const 65535)) "out of bounds memory access")
95101

96102
;; Load/Store v128 data with invalid offset
97103

test/core/simd/simd_load_extend.wast

+25
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
(func (export "i16x8.load8x8_s_offset0_align1") (param $0 i32) (result v128)
5656
(i16x8.load8x8_s offset=0 align=1 (local.get $0))
5757
)
58+
(func (export "i16x8.load8x8_s_offset1_align1") (param $0 i32) (result v128)
59+
(i16x8.load8x8_s offset=1 align=1 (local.get $0))
60+
)
5861
(func (export "i16x8.load8x8_s_offset10_align4") (param $0 i32) (result v128)
5962
(i16x8.load8x8_s offset=10 align=4 (local.get $0))
6063
)
@@ -70,6 +73,9 @@
7073
(func (export "i16x8.load8x8_u_offset0_align1") (param $0 i32) (result v128)
7174
(i16x8.load8x8_u offset=0 align=1 (local.get $0))
7275
)
76+
(func (export "i16x8.load8x8_u_offset1_align1") (param $0 i32) (result v128)
77+
(i16x8.load8x8_u offset=1 align=1 (local.get $0))
78+
)
7379
(func (export "i16x8.load8x8_u_offset10_align4") (param $0 i32) (result v128)
7480
(i16x8.load8x8_u offset=10 align=4 (local.get $0))
7581
)
@@ -86,6 +92,9 @@
8692
(func (export "i32x4.load16x4_s_offset0_align1") (param $0 i32) (result v128)
8793
(i32x4.load16x4_s offset=0 align=1 (local.get $0))
8894
)
95+
(func (export "i32x4.load16x4_s_offset1_align1") (param $0 i32) (result v128)
96+
(i32x4.load16x4_s offset=1 align=1 (local.get $0))
97+
)
8998
(func (export "i32x4.load16x4_s_offset10_align4") (param $0 i32) (result v128)
9099
(i32x4.load16x4_s offset=10 align=4 (local.get $0))
91100
)
@@ -101,6 +110,9 @@
101110
(func (export "i32x4.load16x4_u_offset0_align1") (param $0 i32) (result v128)
102111
(i32x4.load16x4_u offset=0 align=1 (local.get $0))
103112
)
113+
(func (export "i32x4.load16x4_u_offset1_align1") (param $0 i32) (result v128)
114+
(i32x4.load16x4_u offset=1 align=1 (local.get $0))
115+
)
104116
(func (export "i32x4.load16x4_u_offset10_align4") (param $0 i32) (result v128)
105117
(i32x4.load16x4_u offset=10 align=4 (local.get $0))
106118
)
@@ -117,6 +129,9 @@
117129
(func (export "i64x2.load32x2_s_offset0_align1") (param $0 i32) (result v128)
118130
(i64x2.load32x2_s offset=0 align=1 (local.get $0))
119131
)
132+
(func (export "i64x2.load32x2_s_offset1_align1") (param $0 i32) (result v128)
133+
(i64x2.load32x2_s offset=1 align=1 (local.get $0))
134+
)
120135
(func (export "i64x2.load32x2_s_offset10_align4") (param $0 i32) (result v128)
121136
(i64x2.load32x2_s offset=10 align=4 (local.get $0))
122137
)
@@ -132,6 +147,9 @@
132147
(func (export "i64x2.load32x2_u_offset0_align1") (param $0 i32) (result v128)
133148
(i64x2.load32x2_u offset=0 align=1 (local.get $0))
134149
)
150+
(func (export "i64x2.load32x2_u_offset1_align1") (param $0 i32) (result v128)
151+
(i64x2.load32x2_u offset=1 align=1 (local.get $0))
152+
)
135153
(func (export "i64x2.load32x2_u_offset10_align4") (param $0 i32) (result v128)
136154
(i64x2.load32x2_u offset=10 align=4 (local.get $0))
137155
)
@@ -212,6 +230,13 @@
212230
(assert_trap (invoke "i64x2.load32x2_s" (i32.const 65529)) "out of bounds memory access")
213231
(assert_trap (invoke "i64x2.load32x2_u" (i32.const 65529)) "out of bounds memory access")
214232

233+
(assert_trap (invoke "i16x8.load8x8_s_offset1_align1" (i32.const -1)) "out of bounds memory access")
234+
(assert_trap (invoke "i16x8.load8x8_u_offset1_align1" (i32.const -1)) "out of bounds memory access")
235+
(assert_trap (invoke "i32x4.load16x4_s_offset1_align1" (i32.const -1)) "out of bounds memory access")
236+
(assert_trap (invoke "i32x4.load16x4_u_offset1_align1" (i32.const -1)) "out of bounds memory access")
237+
(assert_trap (invoke "i64x2.load32x2_s_offset1_align1" (i32.const -1)) "out of bounds memory access")
238+
(assert_trap (invoke "i64x2.load32x2_u_offset1_align1" (i32.const -1)) "out of bounds memory access")
239+
215240
;; type check
216241
(assert_invalid (module (memory 0) (func (result v128) (i16x8.load8x8_s (f32.const 0)))) "type mismatch")
217242
(assert_invalid (module (memory 0) (func (result v128) (i16x8.load8x8_u (f32.const 0)))) "type mismatch")

test/core/simd/simd_load_splat.wast

+5
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@
138138
(assert_trap (invoke "v64x2.offset2_align4" (i32.const 65528)) "out of bounds memory access")
139139
(assert_trap (invoke "v64x2.offset15_align8" (i32.const 65528)) "out of bounds memory access")
140140

141+
(assert_trap (invoke "v8x16.offset1_align1" (i32.const -1)) "out of bounds memory access")
142+
(assert_trap (invoke "v16x8.offset1_align1" (i32.const -1)) "out of bounds memory access")
143+
(assert_trap (invoke "v32x4.offset1_align1" (i32.const -1)) "out of bounds memory access")
144+
(assert_trap (invoke "v64x2.offset1_align2" (i32.const -1)) "out of bounds memory access")
145+
141146
(assert_trap (invoke "v8x16.offset65536" (i32.const 0)) "out of bounds memory access")
142147
(assert_trap (invoke "v16x8.offset65535" (i32.const 0)) "out of bounds memory access")
143148
(assert_trap (invoke "v32x4.offset65533" (i32.const 0)) "out of bounds memory access")

0 commit comments

Comments
 (0)