Fix crash when pasting into text editor - #397
nacklequack wants to merge 1 commit into
Conversation
Handle cursor positions beyond stale cached line layout and clamp UTF-8 column calculations to the current document bounds.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe text UI now handles cursor positions beyond cached lines and clamps document indices before calculating line-column spans. ChangesText cursor safety
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Merge Risk: ⚪ Minimal · up to The text editor now safely handles cursor positions while layout reflow is pending, with no unresolved merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit hops past cached lines, Comment |
Text changes invalidate line layout lazily. During that interval, a valid cursor in newly updated text can sit beyond the last cached line. getLineOffsetFromDocIndex() did not handle std::upper_bound() returning end(), causing an invalid line offset and out-of-bounds substr crash. - Handle cursor positions beyond the last cached line while layout is pending - Clamp document and line-start bounds before computing column span Ported from Alchemy PR AlchemyViewer#397 by nacklequack.
|
Integrated in 9157c4a |
Description
Fixes an intermittent viewer crash observed while pasting source code into an LSL script editor.
A native crash dump from Alchemy Test 26.4.0.63546 showed the following failure path:
std::string_view::_Check_offset→std::string_view::substr→LLTextEditor::getLineColumnFromDocIndexText changes invalidate the cached line layout and reflow it lazily. During that interval, a cursor position can be valid for the updated document while extending beyond the final cached line.
getLineOffsetFromDocIndex()did not handlestd::upper_bound()returningend(), resulting in an invalid line start being passed tostd::string_view::substr().This change:
Reproduction
Related Issues
Issue Link: None filed
Checklist
Please ensure the following before requesting review:
ctestreportedTotal Tests: 0).Additional Notes
The complete Windows Release viewer was rebuilt successfully with:
cmake --build build-Windows-vs2026-os --config ReleaseThe patched build remained stable through a full day of use, and the original crash did not recur.
The native dump and Windows Application Error event were analyzed locally. The event reported exception code
0xc0000409; the symbolized dump identified the bounds-check failure described above.