1;;! multi_memory = true 2 3;; unaligned utf16 string 4(assert_trap 5 (component 6 (component $c 7 (core module $m 8 (func (export "") (param i32 i32)) 9 (func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0) 10 (memory (export "memory") 1) 11 ) 12 (core instance $m (instantiate $m)) 13 (func (export "a") (param "a" string) 14 (canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")) 15 ) 16 ) 17 18 (component $c2 19 (import "a" (func $f (param "a" string))) 20 (core module $libc 21 (memory (export "memory") 1) 22 ) 23 (core instance $libc (instantiate $libc)) 24 (core func $f (canon lower (func $f) string-encoding=utf16 (memory $libc "memory"))) 25 (core module $m 26 (import "" "" (func $f (param i32 i32))) 27 28 (func $start (call $f (i32.const 1) (i32.const 0))) 29 (start $start) 30 ) 31 (core instance (instantiate $m (with "" (instance (export "" (func $f)))))) 32 ) 33 34 (instance $c (instantiate $c)) 35 (instance $c2 (instantiate $c2 (with "a" (func $c "a")))) 36 ) 37 "unreachable") 38 39;; unaligned latin1+utf16 string, even with the latin1 encoding 40(assert_trap 41 (component 42 (component $c 43 (core module $m 44 (func (export "") (param i32 i32)) 45 (func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0) 46 (memory (export "memory") 1) 47 ) 48 (core instance $m (instantiate $m)) 49 (func (export "a") (param "a" string) 50 (canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")) 51 ) 52 ) 53 54 (component $c2 55 (import "a" (func $f (param "a" string))) 56 (core module $libc 57 (memory (export "memory") 1) 58 ) 59 (core instance $libc (instantiate $libc)) 60 (core func $f (canon lower (func $f) string-encoding=latin1+utf16 (memory $libc "memory"))) 61 (core module $m 62 (import "" "" (func $f (param i32 i32))) 63 64 (func $start (call $f (i32.const 1) (i32.const 0))) 65 (start $start) 66 ) 67 (core instance (instantiate $m (with "" (instance (export "" (func $f)))))) 68 ) 69 70 (instance $c (instantiate $c)) 71 (instance $c2 (instantiate $c2 (with "a" (func $c "a")))) 72 ) 73 "unreachable") 74 75;; out of bounds utf8->utf8 string 76(assert_trap 77 (component 78 (component $c 79 (core module $m 80 (func (export "") (param i32 i32)) 81 (func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0) 82 (memory (export "memory") 1) 83 ) 84 (core instance $m (instantiate $m)) 85 (func (export "a") (param "a" string) 86 (canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory") 87 string-encoding=utf8) 88 ) 89 ) 90 91 (component $c2 92 (import "a" (func $f (param "a" string))) 93 (core module $libc 94 (memory (export "memory") 1) 95 ) 96 (core instance $libc (instantiate $libc)) 97 (core func $f (canon lower (func $f) string-encoding=utf8 (memory $libc "memory"))) 98 (core module $m 99 (import "" "" (func $f (param i32 i32))) 100 101 (func $start (call $f (i32.const 0x8000_0000) (i32.const 1))) 102 (start $start) 103 ) 104 (core instance (instantiate $m (with "" (instance (export "" (func $f)))))) 105 ) 106 107 (instance $c (instantiate $c)) 108 (instance $c2 (instantiate $c2 (with "a" (func $c "a")))) 109 ) 110 "unreachable") 111