D23721: Fix race condition in TextBuffer

Thomas Schöps 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.

REVISION SUMMARY
  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.

TEST PLAN
  I only tested that the code still works after the change.

REPOSITORY
  R39 KTextEditor

BRANCH
  fix_katetextbuffer_race_condition

REVISION DETAIL
  https://phabricator.kde.org/D23721

AFFECTED FILES
  src/buffer/katetextbuffer.cpp
  src/buffer/katetextbuffer.h

To: thomassc
Cc: kwrite-devel, kde-frameworks-devel, LeGast00n, GB_2, domson, michaelh, ngraham, bruns, demsking, cullmann, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190904/9a74e91f/attachment.html>


More information about the Kde-frameworks-devel mailing list