[Types] Fix missing inverse check for described field in isValidSupertype#8378
Open
sumleo wants to merge 1 commit intoWebAssembly:mainfrom
Open
[Types] Fix missing inverse check for described field in isValidSupertype#8378sumleo wants to merge 1 commit intoWebAssembly:mainfrom
sumleo wants to merge 1 commit intoWebAssembly:mainfrom
Conversation
…type The descriptor field check in isValidSupertype was fully symmetric: if the subtype has no descriptor, then the supertype must also have no descriptor. However, the described field check was missing its else branch, allowing a non-descriptor type to illegally subtype a descriptor type when features are fully enabled. Add the missing else branch so that if the subtype has no describes clause, the supertype must also have no describes clause.
kripken
reviewed
Feb 25, 2026
| // describes clause. | ||
| if (super.described) { | ||
| return false; | ||
| } |
Member
There was a problem hiding this comment.
I believe this is not correct, but the spec changed and I'm not sure - @tlively ?
Member
There was a problem hiding this comment.
This is correct! We do not allow this:
(type $foo (descriptor $super) (struct))
(type $super (sub (describes $foo) (struct)))
(type $sub (sub $super) (struct))
Member
That seems pretty bad. Would you be able to upload a fix for that as well? |
tlively
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
elsebranch inisValidSupertypefor thedescribedfield check, making it symmetric with the existingdescriptorfield check.describesclause can illegally subtype a type that has adescribesclause (i.e., a descriptor type), as long as all features are enabled.descriptorcheck already handles both directions (if sub has no descriptor, super must also have no descriptor), but thedescribedcheck was missing the inverse direction.Details
In
isValidSupertype(src/wasm/wasm-type.cpp), the validation fordescriptoris fully symmetric:But the
describedcheck was missing the else branch:The spec test at
test/spec/descriptors.wast(lines 152-161) already covers this case with anassert_invalidfor "supertype of non-descriptor type cannot be a descriptor". However, the test currently passes for the wrong reason:wasm-shellre-parsesassert_invalidmodules as quoted text modules without features enabled, soTypeBuilder::build()rejects the module withRequiresCustomDescriptorsbefore ever reachingisValidSupertype. When the module is loaded through the normal inline parse path (with all features enabled), the invalid subtyping relationship is incorrectly accepted.Test plan
wasm-shell test/spec/descriptors.wastpasses all 14 checks (including the one at line 152)