Repository navigation
[naga wgsl-in] Reject loads of types that contain atomics - #10458
Conversation
apply_load_rule only rejected a load when the pointee was itself an atomic, so `let x = s;` with `s` a struct holding an atomic lowered to a Load of that struct. The HLSL backend then hit unreachable!() in storage.rs. Check the pointee recursively through struct members and array bases. is_atomic_pointer keeps its meaning, since the backends rely on it. The return_atomic case in invalid_functions now fails in the front end instead of the validator. NonConstructibleReturnType is still covered by return_pointer. Fixes gfx-rs#10046.
ErichDonGubler
left a comment
There was a problem hiding this comment.
The fix itself LGTM, just a couple of nits.
It has a single caller in apply_load_rule and doesn't need to live as a top-level function.
|
I went looking for this before answering, rather than guessing. Checked out the CTS at the revision we pin ( They cover atomic type declaration and parsing, address-space restrictions, direct access to a bare atomic variable, and constructibility of an atomic-containing struct as a function return value or in a phony assignment. None of them cover the actual path this fix closes: loading a whole value (struct or array) whose type recursively contains a nested atomic member, through a pointer, several levels of struct/array nesting deep. The closest case is So there's nothing to point a Separately, and unrelated to this PR: If you'd still like CTS-level coverage for this exact case, I can write a new case upstream in gpuweb/cts (extending |
|
This change LGTM now. Congrats, your first wgpu contribution! 🎉 I want to publicly observe that there seems to have been a lot of relatively unedited LLM output with this PR. This makes it much harder to collaborate, because the review process is all about getting a clear signal that at change is beneficial enough to merge. Assuming that guess is right, note that in the future, we may reject such contributions on basis of too much shepherding effort vs. the time you yourself may have put in. |
|
@Mergifyio queue |
Connections
Fixes #10046.
Description
apply_load_ruleonly rejected a load when the pointee was itself an atomic, so loading a struct or array that merely contained an atomic member sailed through the WGSL front end and hitunreachable!()in the HLSL backend. The fix walks the pointee type recursively through struct members and array bases so any nested atomic is caught as a normal WGSL error instead of a panic.Testing
cargo test -p naga --all-features --test naga wgsl_errors::: 358 passed, 0 failed here, versus 356 passed, 0 failed on the merge-base withorigin/trunk. The two extra cases are the new/updated regression tests, and both pass.Squash or Rebase?
Single commit; fine to rebase as-is.
LLM Use?
An LLM-assisted agent helped locate the recursive-type-walk fix and write the accompanying test. I reviewed the diff, understand the root cause and the fix, and take responsibility for the code.
Checklist
This PR was automatically created by an Agent.
The description was automatically written by an Agent.
I self-reviewed and fully understand this PR.
CHANGELOG.mdentries for the user-facing effects of this change are present.The PR is minimal, and doesn't make sense to land as multiple PRs. (not run as a check — judgment call, believed true but unverified against repo policy)
Commits are logically scoped and individually reviewable. (single commit, not separately re-checked)
The PR description has enough context to understand the motivation and solution implemented. (left for reviewers to judge)
(If applicable) WebGPU implementations built with
wgpumay be affected behaviorally. (not evaluated)(If applicable) Validation and feature gates are in place to confine behavioral changes. (not applicable, not verified)
(If applicable) Tests demonstrate the validation and altered logic works. (
cargo test -p naga --all-features --test naga wgsl_errors::run on this HEAD, 358 passed 0 failed, verified discriminating against the pre-fix baseline)