Fix out-of-bounds read in bdsqr_lower2upper (ROCM-21372)#7915
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
In bdsqr_lower2upper(), array E has logical length n-1. The loop runs for i = 0 to n-2, and on the last iteration (i == n-2) the expression E[i+1] evaluates to E[n-1], which is past the end of the array. Add a bounds guard so the out-of-bounds read is avoided: g = ((i + 1) < (n - 1)) ? E[i + 1] : 0;
Copilot
AI
changed the title
[WIP] Fix out-of-bounds read in bdsqr_lower2upper
Fix out-of-bounds read in bdsqr_lower2upper (ROCM-21372)
May 30, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an out-of-bounds read in the GPU bdsqr_lower2upper kernel where the final loop iteration read E[n-1] past the end of the length-n-1 array. The value loaded into g on the last iteration is unused (no next lartg call occurs), so substituting 0 preserves behavior while eliminating the invalid access.
Changes:
- Guard
g = E[i + 1]with a bounds check, returning0on the last iteration.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (77.83%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #7915 +/- ##
========================================
Coverage 61.43% 61.43%
========================================
Files 2091 2091
Lines 358852 358852
Branches 54266 54266
========================================
Hits 220451 220451
Misses 119672 119672
Partials 18729 18729
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
In
bdsqr_lower2upper(), arrayEhas lengthn-1, but the final loop iteration (i == n-2) readsE[i+1]→E[n-1], which is past the end of the array. This affects all data types via the templated implementation (float, double, complex float, complex double).Change
rocauxiliary_bdsqr.hppline 519: Guard the read with a bounds check; use0on the last iteration sincegonly seeds the next (non-existent) loop iteration.Original prompt
This pull request was created from Copilot chat.