Fix crash in extendSelection
AbandonedPublic

Authored by pavelkh on Dec 23 2018, 1:36 PM.

Details

Summary

Fix crash when doing word selection or line selection
and moving the cursor to the end of the screen.
After 4e09f089f940335bdd628139e870ba99721fddfa
Konsole tries to read out of bounds when you double
click to select a whole empty line, and hold down the
mouse button and drag to the right.

Note: still crashes with on some extendSelections
such when y=-1

BUG: 402452

Test Plan

Doesn't crash anymore, selecting the last column works,
both in normal selection, line selection and word selection.

Diff Detail

Repository
R319 Konsole
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
pavelkh requested review of this revision.Dec 23 2018, 1:36 PM
pavelkh created this revision.

I can still get crashes extending selections

#4 0x00007ffff78b95e1 in Konsole::TerminalDisplay::loc (this=0x7120b0, x=42,

y=-1)
at /home/kurthindenburg/Devel/KDE/src/kde/applications/konsole/src/TerminalDisplay.cpp:86

86 Q_ASSERT(y >= 0 && y < _lines);
(gdb) p _lines
$1 = 24

pavelkh updated this revision to Diff 48090.Dec 23 2018, 6:50 PM

All right, full bounds check it is. I could also reproduce y=-1 for the resized window with overscroll (wasn't resizing the window earlier).

Should work properly now if I determined the cause correctly.

Would you rather we commit this and work on the y=-1 issue afterwards?

Seems safe enough. It would just make debug build behave like the release one because of the same transformations made in loc() after asserts.

The y=-1 issue is probably caused by the same selection-to-coords transformation.

hindenburg accepted this revision.Dec 29 2018, 2:01 PM
hindenburg edited the summary of this revision. (Show Details)
hindenburg edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Dec 29 2018, 2:03 PM
This revision was automatically updated to reflect the committed changes.
Restricted Application added a project: Konsole. · View Herald TranscriptDec 29 2018, 2:04 PM
Restricted Application added a subscriber: konsole-devel. · View Herald Transcript
ngraham reopened this revision.Jan 21 2019, 8:05 PM
ngraham added a subscriber: ngraham.

This patch caused a critical regression on the stable branch: https://bugs.kde.org/show_bug.cgi?id=403117. This issue is affecting users on rolling release distros with KDE Applications 18.12.1.

I have reverted this patch on both the stable branch and master. Please feel free to give it another try, but this time please add an autotest for the failure condition in 403117 so we can make sure it doesn't regress again. Thanks!

This revision is now accepted and ready to land.Jan 21 2019, 8:05 PM

A crash is better than a wrong selection ?

Em seg, 21 de jan de 2019 às 21:05, Nathaniel Graham <
noreply@phabricator.kde.org> escreveu:

ngraham reopened this revision.
ngraham added a comment.
This revision is now accepted and ready to land. View Revision
https://phabricator.kde.org/D17757

This patch caused a critical regression on the stable branch:
https://bugs.kde.org/show_bug.cgi?id=403117. This issue is affecting
users on rolling release distros with KDE Applications 18.12.1.

I have reverted this patch on both the stable branch and master. Please
feel free to give it another try, but this time please add an autotest for
the failure condition in 403117 so we can make sure it doesn't regress
again. Thanks!

*REPOSITORY*
R319 Konsole

*REVISION DETAIL*
https://phabricator.kde.org/D17757

*To: *pavelkh, Konsole, hindenburg
*Cc: *ngraham, konsole-devel, thsurrel, maximilianocuria, hindenburg

Can't break a feature in a minor version (.0 -> .1) on the stable branch. That's why we have stable branches. Let's focus on fixing the crash without regressing anything for 18.12.2.

It's ok that the change won't land in prod: release build doesn't have the crash, since it comes from Q_ASSERT, after which the value is properly clamped.

Abandoning this revision to avoid conflicts with Martin Sandsmark's branch that's actively worked on.

You'll need to formally Abandon it using the Add Action... combobox that's above the comment field.

pavelkh abandoned this revision.Jan 23 2019, 10:48 PM

Thanks for the help! Didn't find the proper way of doing it with Ctrl+F.