Crash when replacing new lines with spaces
AbandonedPublic

Authored by dhaumann on Jul 2 2017, 9:45 PM.

Details

Reviewers
jsalatas
Group Reviewers
KTextEditor
Summary

BUG: 381080

Test Plan

The problem was that it looked for multiline pattern only in case of a RegExp search. I extended it to also look for multiline pattern also in case of EscapeSequence search, which seems to fix the problem.

Notice: I haven't checked but I strongly believe that the isMultiLine() will return false positives in case of EscapeSequence searches. Although this may create a small annoyance to the user (moving the cursor to another line), I believe it is still a better approach than just let it crash. In any case I would appreciate any suggestions on how to handle it in a better way.

Diff Detail

Repository
R39 KTextEditor
Lint
Lint Skipped
Unit
Unit Tests Skipped
jsalatas created this revision.Jul 2 2017, 9:45 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJul 2 2017, 9:45 PM
Restricted Application added subscribers: Frameworks, kwrite-devel. · View Herald Transcript

If the review is accepted and you want to close the bug, replace

Fixes bug 381080
https://bugs.kde.org/show_bug.cgi?id=381080

with simply

BUG: 381080

If the review is accepted and you want to close the bug, replace

Fixes bug 381080
https://bugs.kde.org/show_bug.cgi?id=381080

with simply

BUG: 381080

Thanks!

I'm aware of that. I just wanted to make the lives of the reviewers a little bit easier :)

If the review is accepted and you want to close the bug, replace

Fixes bug 381080
https://bugs.kde.org/show_bug.cgi?id=381080

with simply

BUG: 381080

Thanks!

I'm aware of that. I just wanted to make the lives of the reviewers a little bit easier :)

But if the review is accepted as it is now, you would have to change it before committing. Better prepare it in the final form.

jsalatas edited the summary of this revision. (Show Details)Jul 2 2017, 10:45 PM
kfunk added a subscriber: kfunk.Jul 11 2017, 9:26 PM

Could you add a test in e.g. autotests/src/searchbar_test.cpp?

In D6473#124287, @kfunk wrote:

Could you add a test in e.g. autotests/src/searchbar_test.cpp?

Sure! will do it later...

I'm not an expert in the search code - in general your fix looks sane (had a look into the KateRegExp class). A unit test indeed would be helpful, since it will allow us to not break the search code again.

...thining a bit more about this: What I dislike is the fact that we don't seem to understand why it crashes in the first place, right? The problem is that the cursor of the view is not updated, so it is behind the document end in an invalid line. And moving the cursor up will again put it into an invalid line, which crashes.

So the question is: Why is the cursor not updated? If we can answer this, we may be able to either find that this patch is correct, or that the root of the real issue lies somewhere else...

So the question is: Why is the cursor not updated? If we can answer this, we may be able to either find that this patch is correct, or that the root of the real issue lies somewhere else...

Hmmmm..... I need to go through that again and let you know....

anthonyfieroni added a subscriber: anthonyfieroni.EditedJul 12 2017, 6:52 AM

https://phabricator.kde.org/source/ktexteditor/browse/master/src/render/katelayoutcache.cpp;ad51cece443bc6bb643fa4ca94293a13d3c2f852$321
The problem is `realLine >= m_renderer->doc()->lines()` it return a nullptr. First of all https://phabricator.kde.org/source/ktexteditor/browse/master/src/render/katelayoutcache.cpp;ad51cece443bc6bb643fa4ca94293a13d3c2f852$368 should be checked against nullptr, even all other places that line(..) is used or better handling of corner case.

mwolff added a subscriber: mwolff.Nov 19 2017, 10:13 PM

ping? can this be merged? can a unit test be written?

dhaumann requested changes to this revision.Aug 14 2018, 1:54 PM

I was just about to merge this patch. But the crash still happens for me also with this patch - so it's still not fixed.

This revision now requires changes to proceed.Aug 14 2018, 1:54 PM
Restricted Application added a project: Kate. · View Herald TranscriptAug 14 2018, 1:54 PM
Restricted Application edited subscribers, added: kde-frameworks-devel; removed: Frameworks. · View Herald Transcript

About me when line(...) is accessed it should check for nullptr as well

if (auto l = line(a)) {
    return l->accessor();
}

https://phabricator.kde.org/source/ktexteditor/browse/master/src/render/katelayoutcache.cpp;ad51cece443bc6bb643fa4ca94293a13d3c2f852$322 because m_renderer->doc()->lines() is bigger than lines

Hm, can you send a patch that fixes this? :-)

I'm aware of that it will fix the crash but functionally still will be missing, but i'll give a try.

dhaumann commandeered this revision.Aug 14 2018, 4:26 PM
dhaumann edited reviewers, added: jsalatas; removed: dhaumann.

Reassign

dhaumann abandoned this revision.Aug 14 2018, 4:26 PM

Fixed in D14847 in a different way.