WebAssembly / spec

WebAssembly specification, reference interpreter, and test suite.
https://webassembly.github.io/spec/
Other
3.11k stars 439 forks source link

Not enough unreachability/side-effects tests #1644

Open SoniEx2 opened 1 year ago

SoniEx2 commented 1 year ago

While a real compiler should never emit code like

(module
  (global $a (mut i32) (i32.const 0))

  (func (export "get-a") (result i32) (global.get $a))

  (func $set-and-return-a (result i32) (global.set $a (i32.const 1)) (global.get $a))

  (func (export "call-unreachable") (result i32)
    (call $set-and-return-a)
    (unreachable)
  )
)

(assert_trap (invoke "call-unreachable") "unreachable")
(assert_return (invoke "get-a") (i32.const 1))

it would be nice to see more tests like this.

rossberg commented 1 year ago

Agreed. The tests in unreachable.wast do not currently test for order of effects.

There are quite a few tests for stack polymorphism, which are in unreached-[in]valid.wast. Your example above is unrelated to stack polymorphism, however, so I don't know what you have in mind in that regard.

SoniEx2 commented 1 year ago

hmm we thought we had reported a stack polymorphism bug somewhere but now we don't see it either... :woman_shrugging:

edit: ah, it was in the exception handling proposal.