WebAssembly / stack-switching

A repository for the stack switching proposal.
Other
146 stars 13 forks source link

Gracefully exit on unhandled tag #93

Closed dhil closed 2 months ago

dhil commented 2 months ago

This patch fixes #92 such that the interpreter exits gracefully on an unhandled tag.

$ cat test.wast
(module
  (type $f1 (func))
  (type $c1 (cont $f1))
  (tag $e)
  (func $s (suspend $e))
  (elem declare func $s)
  (func (export "main")
    (resume $c1 (cont.new $c1 (ref.func $s)))
  )
)
$ ./wasm test.wast
test.wast:5.12-5.24: suspension error: unhandled tag
rossberg commented 2 months ago

~Perhaps add this as a test case?~

Sorry, strike that, makes no sense.

dhil commented 2 months ago

~Perhaps add this as a test case?~

Sorry, strike that, makes no sense.

Exactly. I realised this myself when the testsuite kept failing, despite the fix being correct :-))

titzer commented 2 months ago

~Perhaps add this as a test case?~ Sorry, strike that, makes no sense.

Exactly. I realised this myself when the testsuite kept failing, despite the fix being correct :-))

Can you just add an assert_trap to this test?

dhil commented 2 months ago

~Perhaps add this as a test case?~ Sorry, strike that, makes no sense.

Exactly. I realised this myself when the testsuite kept failing, despite the fix being correct :-))

Can you just add an assert_trap to this test?

Not as it is now. It would count as a "failure", as the exception Eval.Suspension is caught outside the Wast directive driver. So, the Wast driver is exited, meaning no further tests are run.

Same thing happens for Wasm exceptions, e.g.

(module
  (type $f1 (func))
  (tag $e)
  (func (export "main")
    (throw $e)
  )
)

(assert_trap (invoke "main") "uncaught exception")

This program fails in a similar manner as it does not pass the trap assertion.

titzer commented 2 months ago

Same thing happens for Wasm exceptions, e.g.

(assert_trap (invoke "main") "uncaught exception")



This program fails in a similar manner as it does not pass the trap assertion.

Got it, thanks. So the test should have an assert_suspension