8585 (func (export "test")
8686 (data.drop 0)
8787 (data.drop 0)))
88- (assert_trap ( invoke "test") "data segment dropped ")
88+ (invoke "test")
8989` ) ;
9090
9191// drop, then init
9595 (func (export "test")
9696 (data.drop 0)
9797 (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1))))
98- (assert_trap (invoke "test") "data segment dropped ")
98+ (assert_trap (invoke "test") "out of bounds ")
9999` ) ;
100100
101101// init with data seg ix indicating an active segment
@@ -105,7 +105,7 @@ print(
105105 (data (i32.const 0) "\\37")
106106 (func (export "test")
107107 (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1))))
108- (assert_trap (invoke "test") "data segment dropped ")
108+ (assert_trap (invoke "test") "out of bounds ")
109109` ) ;
110110
111111// init with no memory
@@ -164,13 +164,13 @@ print(
164164(assert_trap (invoke "test") "out of bounds")
165165` ) ;
166166
167- // init: seg ix is valid passive, src offset past the end, zero len is always valid
167+ // init: seg ix is valid passive, src offset past the end, zero len is invalid
168168print (
169169`(module
170170 ${ PREAMBLE }
171171 (func (export "test")
172172 (memory.init 0 (i32.const 1234) (i32.const 4) (i32.const 0))))
173- (invoke "test")
173+ (assert_trap ( invoke "test") "out of bounds ")
174174` ) ;
175175
176176// init: seg ix is valid passive, zero len, src offset at the end
@@ -182,13 +182,13 @@ print(
182182(invoke "test")
183183` ) ;
184184
185- // init: seg ix is valid passive, dst offset past the end, zero len is always valid
185+ // init: seg ix is valid passive, dst offset past the end, zero len is invalid
186186print (
187187`(module
188188 ${ PREAMBLE }
189189 (func (export "test")
190190 (memory.init 0 (i32.const 0x10001) (i32.const 0) (i32.const 0))))
191- (invoke "test")
191+ (assert_trap ( invoke "test") "out of bounds ")
192192` ) ;
193193
194194// init: seg ix is valid passive, zero len, but dst offset at the end
@@ -209,6 +209,16 @@ print(
209209(invoke "test")
210210` ) ;
211211
212+ // init: seg ix is valid passive, src and dst offset past the end, zero len is
213+ // invalid
214+ print (
215+ `(module
216+ ${ PREAMBLE }
217+ (func (export "test")
218+ (memory.init 0 (i32.const 0x10001) (i32.const 4) (i32.const 0))))
219+ (assert_trap (invoke "test") "out of bounds")
220+ ` ) ;
221+
212222// invalid argument types. TODO: can add anyfunc etc here.
213223{
214224 const tys = [ 'i32' , 'f32' , 'i64' , 'f64' ] ;
0 commit comments