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 spv-out msl-out hlsl-out] Make infinite loop workaround count down instead of up #7372

Merged
merged 3 commits into from
Mar 21, 2025

Conversation

jamienicol
Copy link
Contributor

Connections
Fixes #7319

Description
To avoid generating code containing infinite loops, and therefore incurring the wrath of undefined behaviour, we insert a counter into each loop that will break after 2^64 iterations. This was previously implemented as two u32 variables counting up from zero.

We have been informed that this construct can cause certain Intel drivers to hang. Instead, we must count down from u32::MAX. Counting down is more fun, anyway.

Testing
Inspected snapshot changes

Squash or Rebase?

Either

Checklist

  • Run cargo fmt.
  • Run cargo clippy --tests. If applicable, add:
  • Run cargo xtask test to run tests.

Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

Pretty straightforward! LGTM! 🤘🏻

@ErichDonGubler ErichDonGubler force-pushed the infinite-loop-count-down branch from a2efe8b to b4f25d2 Compare March 20, 2025 18:46
@ErichDonGubler
Copy link
Member

Rebased to resolve conflicts, and added a couple of fixup!s. You may fire when ready!
you-may-fire-when-ready

@ErichDonGubler ErichDonGubler self-assigned this Mar 20, 2025
jamienicol and others added 3 commits March 20, 2025 15:01
…own instead of up

To avoid generating code containing infinite loops, and therefore
incurring the wrath of undefined behaviour, we insert a counter into
each loop that will break after 2^64 iterations. This was previously
implemented as two u32 variables counting up from zero.

We have been informed that this construct can cause certain Intel
drivers to hang. Instead, we must count down from u32::MAX. Counting
down is more fun, anyway.
@ErichDonGubler ErichDonGubler force-pushed the infinite-loop-count-down branch from b4f25d2 to c8d8de6 Compare March 20, 2025 19:01
@jamienicol jamienicol merged commit 894d036 into gfx-rs:trunk Mar 21, 2025
37 checks passed
@jamienicol jamienicol deleted the infinite-loop-count-down branch March 21, 2025 08:24
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.

[naga] Infinite loop mitigation needs to count down, not up
2 participants