Repository navigation
Leave a valid destination when f throws inside map! or broadcast! - #1082
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1082 +/- ##
==========================================
- Coverage 94.77% 94.75% -0.02%
==========================================
Files 16 16
Lines 9917 9958 +41
==========================================
+ Hits 9399 9436 +37
- Misses 518 522 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ViralBShah
enabled auto-merge (squash)
October 13, 2026 05:28
ViralBShah
commented
Oct 13, 2026
ViralBShah
left a comment
Member
Author
There was a problem hiding this comment.
Reviewed by Codex at bd3ad1c.
No actionable findings. The guards surround the pattern-building kernels, preserve the same-pattern unary case, and clear partial mutable structure after other failures; fixed destinations retain their existing path. The preflight fill conversion remains outside the mutation region.
ViralBShah
force-pushed
the
vs/map-throw-valid-dest
branch
from
October 13, 2026 05:31
bd3ad1c to
78ea5b2
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ViralBShah
force-pushed
the
vs/map-throw-valid-dest
branch
from
October 13, 2026 05:34
78ea5b2 to
674de31
Compare
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
f, or the conversion of its result to the destination's element type, throws part-way through an in-placemap!orbroadcast!, the sparse destination is left with a pattern that is half-written: column pointers of the new result next to those of the old one. The next use of it fails an internal assertion or reads the wrong entries.Before (on #1071; the same on
mainand Julia 1.13)After
The kernels rebuild the pattern of the destination, or densify it, as they go, so a throw from
fleaves it between two patterns. The dispatchers ofmap!andbroadcast!now call the kernel inside atry(_guardpatternfor the zero-preserving kernels, the existing_guardfillfor those that fill, and the zero-argumentC .= f.()path), and on a throw empty the destination before rethrowing. The kernels themselves are unchanged.Behaviour to review: after a throw, a destination that is not fixed is in one of three states, never structurally invalid.
f(0)does not convert. That is Validate before densifying the destination ofmap!andbroadcast!#1071.C .= f.(C)). This is whatmaindoes.A fixed destination keeps its pattern throughout, as before. Truncating at the failing column instead of emptying needs loop state in the
catch, which costs the hot loop.The
tryis outside the kernels. Minimum of 15 runs, time in ms and allocated bytes,n = 10^5square with about 10^6 stored entries per argument (map!(cos, C, A): a 1000×1000 destination, all 10^6 entries stored):map(sin, A)map(+, A, B)A .* Bmap!(+, C, A, B)C .= A .+ Bmap!(cos, C, A)The out-of-place rows do not go through the new code. The inferred result types of all six are unchanged.
Split from #1022.
Backport: this fixes a corrupted destination, but it also changes what a destination holds after a throw (empty, where it used to be invalid but with some of its old entries readable), so it is a behaviour change as well as a fix.
Written by Claude Code.
🤖 Generated with Claude Code