Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Conversation

@CharlieTap
Copy link
Contributor

This is another one I found whilst implementing the spec. A rather confusing one to be honest 😓

Effectively if you take the frame at the beginning of the instruction, you may be executing inside an imported function and thus have a different module instance in your stack frame. As part of finding the handler, you unwind the stack and exit this imported function but you are still referencing its module instance. When you then perform the check that attempts to match the tag you would be looking up tag within the wrong module instance.

This test helped me find it:

(module
  (func $imported-throw (import "test" "throw"))
  (tag $e0)

  (func (export "imported-mismatch") (result i32)
    (block $h
      (try_table (result i32) (catch_all $h)
        (block $h0
          (try_table (result i32) (catch $e0 $h0)
            (i32.const 1)
            (call $imported-throw)
          )
          (return)
        )
        (i32.const 2)
      )
      (return)
    )
    (i32.const 3)
  )
)

Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@rossberg rossberg merged commit 24f0819 into WebAssembly:main Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants