<table><tr><td style="">thomassc created this revision.<br />Herald added projects: Kate, Frameworks.<br />Herald added subscribers: kde-frameworks-devel, kwrite-devel.<br />thomassc requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D23721">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>In the "shortcut: try last block first" branch in TextBuffer::blockForLine(),<br />
m_lastUsedBlock is accessed multiple times. If another tread simultaneously<br />
executes the binary block search below in the same function, then<br />
m_lastUsedBlock may be modified by that thread. This may result in the first<br />
thread returning a wrong block, since it may return the modified value of<br />
m_lastUsedBlock instead of the original value that it used to determine whether<br />
the given line is in the block.</p>

<p>This change is intended to fix a crash where an out-of-bounds line is accessed<br />
in katetextblock.cpp, which occurs about one or two times per month for me when<br />
using KDevelop. I have no idea whether this possible race condition is actually<br />
the reason for these crashes, but it seems like a plausible candidate.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>I only tested that the code still works after the change.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>BRANCH</strong><div><div>fix_katetextbuffer_race_condition</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D23721">https://phabricator.kde.org/D23721</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/buffer/katetextbuffer.cpp<br />
src/buffer/katetextbuffer.h</div></div></div><br /><div><strong>To: </strong>thomassc<br /><strong>Cc: </strong>kwrite-devel, kde-frameworks-devel, LeGast00n, GB_2, domson, michaelh, ngraham, bruns, demsking, cullmann, sars, dhaumann<br /></div>