Fix out-of-bounds access in is_hermsym for stored zeros - #741
Open
KristofferC wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #741 +/- ##
=======================================
Coverage 84.34% 84.35%
=======================================
Files 13 13
Lines 9373 9375 +2
=======================================
+ Hits 7906 7908 +2
Misses 1467 1467 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Apparently, we need to backport to all the way to v0.4! |
Member
Author
|
I ran out of labels! |
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.
When old sins come back to haunt you.... (I am responsible for this bug 11 years ago)... I made Claude do some archaeology:
History of the
is_hermsymout-of-bounds bugThe specific crashing loop is from JuliaLang/julia#15504, but the bug lineage starts at JuliaLang/julia#11371 — a version of this out-of-bounds hole has existed continuously since May 2015. Here is what an empirical run of each historical version of the algorithm shows:
truefalsefalse✓falsefalsetrue✓true✓truefalse✓falseThe history reads like a game of whack-a-mole:
is_hermsymwith an unguardedrowval[tracker[row]]read — already out-of-bounds-capable (reported as JuliaLang/julia#16521), and it returned a silently wrongtrueon today's test matrix.offset += 1; row2 = rowval[offset]is exactly the line that throws in today's crasher. So the precise bug fixed here was born there.offset > length(rowval)guard — but only before the first read, and with the wrong bound (end ofrowvalinstead of end of the column). It fixed the no-stored-zeros case and left the stored-zeros hole open for another decade.@inbounds, quietly upgrading the remainingBoundsErrorto undefined behavior.So if you want a single answer: JuliaLang/julia#15504 wrote the line that crashes, but it was replacing a JuliaLang/julia#11371 line that gave a wrong answer on the same input. This fix is the third patch to the same ten-line region, all chasing the original 2015 tracker design.