D23721: Fix race condition in TextBuffer
noreply at phabricator.kde.org
Wed Sep 4 17:36:01 BST 2019
thomassc created this revision.
Herald added projects: Kate, Frameworks.
Herald added subscribers: kde-frameworks-devel, kwrite-devel.
thomassc requested review of this revision.
In the "shortcut: try last block first" branch in TextBuffer::blockForLine(),
m_lastUsedBlock is accessed multiple times. If another tread simultaneously
executes the binary block search below in the same function, then
m_lastUsedBlock may be modified by that thread. This may result in the first
thread returning a wrong block, since it may return the modified value of
m_lastUsedBlock instead of the original value that it used to determine whether
the given line is in the block.
This change is intended to fix a crash where an out-of-bounds line is accessed
in katetextblock.cpp, which occurs about one or two times per month for me when
using KDevelop. I have no idea whether this possible race condition is actually
the reason for these crashes, but it seems like a plausible candidate.
I only tested that the code still works after the change.
Cc: kwrite-devel, kde-frameworks-devel, LeGast00n, GB_2, domson, michaelh, ngraham, bruns, demsking, cullmann, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the KWrite-Devel