Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm2c exception handling is broken #2203

Closed
SoniEx2 opened this issue Apr 20, 2023 · 3 comments · Fixed by #2204
Closed

wasm2c exception handling is broken #2203

SoniEx2 opened this issue Apr 20, 2023 · 3 comments · Fixed by #2204

Comments

@SoniEx2
Copy link
Contributor

SoniEx2 commented Apr 20, 2023

;;; TOOL: run-spec-wasm2c
;;; ARGS*: --enable-exceptions
(module
  (tag $e0)
  (func $throw (throw $e0))
  (func (export "break-throw") (result i32)
    (try $outer (result i32)
      (do
        (try (result i32)
          (do
            (block $a
              (try (do (br $a)) (delegate $outer))
            )
            (call $throw)
            (i32.const 0)
          )
          (catch $e0 (i32.const 1))
        )
      )
      (catch $e0 (i32.const 2))
    )
  )
)

(assert_return (invoke "break-throw") (i32.const 1))
(;; STDOUT ;;;
1/1 tests passed.
;;; STDOUT ;;)
@SoniEx2
Copy link
Contributor Author

SoniEx2 commented Apr 20, 2023

this works correctly tho:

;;; TOOL: run-spec-wasm2c
;;; ARGS*: --enable-exceptions
(module
  (tag $e0)
  (func $throw (throw $e0))
  (func (export "break-throw") (result i32)
    (try $outer (result i32)
      (do
        (try (result i32)
          (do
            (block $a (result i32)
              (try (do (br $a (i32.const 0))) (delegate $outer)) (i32.const 0)
            ) (drop)
            (call $throw)
            (i32.const 0)
          )
          (catch $e0 (i32.const 1))
        )
      )
      (catch $e0 (i32.const 2))
    )
  )
)

(assert_return (invoke "break-throw") (i32.const 1))
(;; STDOUT ;;;
1/1 tests passed.
;;; STDOUT ;;)

SoniEx2 added a commit to SoniEx2/wasm2kotlin that referenced this issue Apr 20, 2023
@keithw
Copy link
Member

keithw commented Apr 20, 2023

Thanks -- could you please contribute the test upstream (could reference WebAssembly/exception-handling#210) and then we'll pull it from there and adjust wasm2c to match? Would be good to make sure every implementation agrees on the semantics.

@SoniEx2
Copy link
Contributor Author

SoniEx2 commented Apr 20, 2023

this also seems to work correctly:

;;; TOOL: run-spec-wasm2c
;;; ARGS*: --enable-exceptions
(module
  (tag $e0)
  (func $throw (throw $e0))
  (func (export "break-throw") (result i32)
    (try $outer (result i32)
      (do
        (try (result i32)
          (do
            (block $a
              (try (do (br $a)) (delegate $outer))
            )
            (throw $e0)
            (i32.const 0)
          )
          (catch $e0 (i32.const 1))
        )
      )
      (catch $e0 (i32.const 2))
    )
  )
)

(assert_return (invoke "break-throw") (i32.const 1))
(;; STDOUT ;;;
1/1 tests passed.
;;; STDOUT ;;)

@keithw keithw mentioned this issue Apr 20, 2023
keithw pushed a commit to SoniEx2/wasm2kotlin that referenced this issue Apr 21, 2023
aheejin pushed a commit to WebAssembly/exception-handling that referenced this issue May 24, 2024
Tests that breaking out of a try resets the exception handler correctly.

See WebAssembly/wabt#2203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants