Skip to content

Add validation for recursive type count in loader #4440

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kylo5aby
Copy link
Contributor

@kylo5aby kylo5aby commented Jul 1, 2025

No description provided.

if (rec_count == 0) {
set_error_buf(
error_buf, error_buf_size,
"recursive type count should be greater than 0");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about that rec_count can't be 0. Would you mind pointing out the relevant content in the GC spec? https://webassembly.github.io/gc/core/valid/modules.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about that rec_count can't be 0. Would you mind pointing out the relevant content in the GC spec? https://webassembly.github.io/gc/core/valid/modules.html

I think gc spec doesn't describe it explicitly as mentioned in spec. But in this section, it says that

a rec definition defines a group of mutually recursive types that can refer to each other; it thereby defines several type indices at a time
a single type definition, as in Wasm before this proposal, is reinterpreted as a short-hand for a recursive group containing just one type

that means for a rec, it must has at least 2 types, otherwise, it should be a single type.

for the related implementation in binaryen, only emit rec flag when the number of types greater than 1.

Copy link
Collaborator

@lum1n0us lum1n0us left a comment

Choose a reason for hiding this comment

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

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.

2 participants