|
| 1 | +;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited. |
| 2 | + |
| 3 | +;; RUN: foreach %s %t wasm-opt -all --fuzz-exec-before -q -o /dev/null 2>&1 | filecheck %s |
| 4 | + |
| 5 | +;; $test will try to suspend through JS. That traps. If it threw a JS exception |
| 6 | +;; instead, we would catch that exception and continue onwards, hitting an |
| 7 | +;; invalid internal state. |
| 8 | + |
| 9 | +(module |
| 10 | + (type $f (func)) |
| 11 | + (type $k (cont $f)) |
| 12 | + |
| 13 | + (import "fuzzing-support" "call-export" (func $call-export (param i32 i32))) |
| 14 | + (import "fuzzing-support" "call-export-catch" (func $call-export-catch (param i32) (result i32))) |
| 15 | + |
| 16 | + (tag $e) |
| 17 | + |
| 18 | + ;; CHECK: [fuzz-exec] calling suspend |
| 19 | + ;; CHECK-NEXT: [exception thrown: unhandled suspend] |
| 20 | + (func $suspend (export "suspend") |
| 21 | + (suspend $e) |
| 22 | + ) |
| 23 | + |
| 24 | + ;; CHECK: [fuzz-exec] calling handle |
| 25 | + ;; CHECK-NEXT: [trap suspend through JS] |
| 26 | + (func $handle (export "handle") |
| 27 | + (drop |
| 28 | + (block $block (result (ref $k)) |
| 29 | + (resume $k (on $e $block) |
| 30 | + (cont.new $k |
| 31 | + (ref.func $suspend-after-host-frame) |
| 32 | + ) |
| 33 | + ) |
| 34 | + (return) |
| 35 | + ) |
| 36 | + ) |
| 37 | + ) |
| 38 | + |
| 39 | + (func $suspend-after-host-frame (type $f) |
| 40 | + (call $call-export |
| 41 | + (i32.const 0) ;; "suspend" |
| 42 | + (i32.const 0) |
| 43 | + ) |
| 44 | + ) |
| 45 | + |
| 46 | + ;; CHECK: [fuzz-exec] calling test |
| 47 | + ;; CHECK-NEXT: [trap suspend through JS] |
| 48 | + (func $test (export "test") |
| 49 | + (drop |
| 50 | + (call $call-export-catch |
| 51 | + (i32.const 1) ;; "handle" |
| 52 | + ) |
| 53 | + ) |
| 54 | + (call $call-export |
| 55 | + (i32.const 0) ;; "suspend" |
| 56 | + (i32.const 1) ;; rethrow exceptions |
| 57 | + ) |
| 58 | + ) |
| 59 | +) |
0 commit comments