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

Properly validate ref.cast when lacking a common supertype #6741

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

kripken
Copy link
Member

@kripken kripken commented Jul 12, 2024

When lacking a common supertype the GLB operation makes the type of the cast
unreachable, which errors on getHeapType in the later code.

Fixes #6738

// earlier), then the cast is unreachable because the cast type had no
// common supertype with the ref, which is invalid. This is the same as the
// check below us, but we must do it first (as getHeapType fails otherwise).
if (!shouldBeUnequal(
Copy link
Member

Choose a reason for hiding this comment

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

We could tighten this up even more by checking that the result type is a reference type. So if it somehow was set to i32 or something, we would still avoid the assertion failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, I added that now as an extra test (it has a more generic error message, and I didn't want to lose the specific explanation for the supertype issue).

@kripken kripken merged commit 353e19e into WebAssembly:main Jul 23, 2024
13 checks passed
@kripken kripken deleted the ref.cast.val.unreach branch July 23, 2024 21:03
@gkdn gkdn mentioned this pull request Aug 31, 2024
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 this pull request may close these issues.

Assertion failed in wasm-as when casting to externref
2 participants