Fix buffer overread setting line-break text in LgLineBreaker - #1057
Merged
Conversation
* Copy the text with the length-taking UnicodeString constructor instead of assigning the bare pointer, which scans an unterminated buffer for a null terminator. * Adds a native regression test covering the copy length and word-break lookup. 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 #1057 +/- ##
==========================================
+ Coverage 38.02% 38.05% +0.02%
==========================================
Files 1499 1499
Lines 349910 350117 +207
Branches 40226 40233 +7
==========================================
+ Hits 133055 133231 +176
- Misses 187577 187603 +26
- Partials 29278 29283 +5
🚀 New features to boost your workflow:
|
thejambi
approved these changes
Aug 12, 2026
thejambi
left a comment
Contributor
There was a problem hiding this comment.
@thejambi reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on jasonleenaylor).
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.
Quick Summary
VerifyScenario("long-prose")/RunBenchmark("long-prose")CI failure — aCOMException: Access violationfromVwRootBox.Layoutthat hit unrelated PRs roughly weekly (five identical failures Jul 16–Aug 10; example run).LgLineBreaker::put_LineBreakTextnow copies its text with the length-takingUnicodeStringconstructor instead of assigning the bare pointer, which scans an unterminated buffer for a null terminator.CI-ready checklist
.github/commit-guidelines.md(subject ≤ 72 chars, no trailing punctuation; if body present, blank line then ≤ 80-char lines).Docs/workflows/ai-pr-workflow.mdand ranpr-preflightor the equivalent branch-readiness review before requesting review.Src/**folders touched, correspondingAGENTS.mdfiles are updated or explicitly confirmed still accurate.Notes for reviewers (optional)
Why it failed.
UniscribeEngine::FindBreakPointhandsput_LineBreakTexta text buffer that carries no null terminator. Storing that text by assigning the bare pointer made ICU scan past the end of the buffer looking for a terminator; the read only faults when the memory after the buffer happens to be unmapped, which is what made the crash rare and heap-layout dependent. It surfaced only in thelong-prosescenario because paragraphs under 1000 characters go through a stack buffer (where the overread never faults), and that scenario has by far the largest heap-allocated paragraph text. The overread shipped with the ICU 70 upgrade (6592f1e, Feb 2022), so real projects with paragraphs over ~1000 characters have been exposed to it since.Verification. Made the crash deterministic with full PageHeap: the scan faulted at exactly
text[cch]insideicuuc70!UnicodeString::doAppendon every long-prose layout before the fix, and not at all after. All 30 render baseline tests pass unchanged (the fix does not alter break positions), and the new nativeTestLgLineBreakertest passes.Related history. The STA attribute added by #919 for these same AVs remains correct and should stay: Views COM objects are apartment-threaded, so the fixtures need
[Apartment(ApartmentState.STA)]regardless — but the AVs it chased were most likely this overread.🤖 Generated with Claude Code
This change is