Bug 329629 - Kate uses 100% CPU on serach and replace in VM emulation mode.
Summary: Kate uses 100% CPU on serach and replace in VM emulation mode.
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: Vi Input Mode (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-05 19:27 UTC by Dotan Cohen
Modified: 2014-02-24 09:48 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.13


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dotan Cohen 2014-01-05 19:27:46 UTC
After selecting several lines then using the following command, KATE locks up the CPU:
:'<,'>s/\s*|\s*/', '/g

After a few minutes I had to kill -9 the Kate process. When I then tried to open the file again in Kate, I got the message that the file was not closed appropriately. When I tried to recover, Kate locked up gain and needed kill -9.

Unfortunately I cannot post the swap file here as it contains sensitive information.

Reproducible: Always
Comment 1 Michal Humpula 2014-01-06 20:54:08 UTC
Hi Dotan,

nice catch!;-) I can replicate and I've already saw what is going on. It's not vi-mode problem. But I'm interested... what were you trying accomplish with that substitution command? If I read it correctly it could pretty much match the "". And the "|\s*" is pretty much an error isn't it? Still the kate should go for endless loop like that.

For the swap file recovery... that command you've wrote caused an enormous amout of changes on the document, so when you've tried to recover, swap recovery process tried to do the same thing as the subtitution command. So that one was actually acting correctly according to input.
Comment 2 Michal Humpula 2014-01-06 23:06:25 UTC
Note to myself or anyone willing to fix it. Problem lies somewhere in
KateCommands::SedReplace::InteractiveSedReplacer::replaceCurrentMatch or
KateRegExpSearch::search
Depends how you look at it.

Be aware of simple fixes that lead to breaking up the "s/$/x/g" case.
Comment 3 Michal Humpula 2014-02-22 20:43:18 UTC
Git commit 9ff1f156d80a2c48386fd58a72401ea6a84d5bce by Michal Humpula.
Committed on 22/02/2014 at 20:41.
Pushed by michalhumpula into branch 'master'.

vi-mode: fix deadly s/\s*/x/g loop
FIXED-IN: 4.13

M  +19   -10   part/utils/katecmds.cpp
M  +2    -0    tests/vimode_test.cpp

http://commits.kde.org/kate/9ff1f156d80a2c48386fd58a72401ea6a84d5bce
Comment 4 Dotan Cohen 2014-02-24 09:48:52 UTC
Great Michal, thank you!