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

[naga] Forbid cycles between global expressions and types. #6800

Conversation

jimblandy
Copy link
Member

Update valid::handles to traverse Module::types and
Module::global_expressions in tandem, to ensure that the types and
expressions are acyclic.

Fixes #6793.

@jimblandy jimblandy added area: validation Issues related to validation, diagnostics, and error handling naga Shader Translator area: naga middle-end Intermediate representation labels Dec 21, 2024
@jimblandy jimblandy requested a review from a team as a code owner December 21, 2024 18:00
Update `valid::handles` to traverse `Module::types` and
`Module::global_expressions` in tandem, to ensure that the types and
expressions are acyclic.

Fixes gfx-rs#6793.
Copy link
Collaborator

@atlv24 atlv24 left a comment

Choose a reason for hiding this comment

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

The comments are spectacular. Would this also catch immediate self-reference of constants? like

const f: f32 = f;

or is it only type <-> expression cycles?

kentslaney added a commit to kentslaney/wgpu that referenced this pull request Jan 3, 2025
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

Looks great, left a question.

match size {
crate::ArraySize::Pending(pending) => match pending {
crate::PendingArraySize::Expression(expr) => Some(expr),
crate::PendingArraySize::Override(_) => None,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't check the override initializer as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, yes, we should.

@cwfitzgerald cwfitzgerald merged commit 6351c2d into gfx-rs:trunk Jan 8, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga middle-end Intermediate representation area: validation Issues related to validation, diagnostics, and error handling naga Shader Translator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[naga] PendingArraySize::Expression handle not validated
4 participants