Bug 354343 - regexp processing allocates whole available RAM and halts the system
Summary: regexp processing allocates whole available RAM and halts the system
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Kubuntu Linux
: VHI crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-25 10:38 UTC by Alexander Trufanov
Modified: 2019-08-24 20:25 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Trufanov 2015-10-25 10:38:33 UTC
My Kate is 15.08.2
Kubuntu 15.10 x64 kernel 4.2.0-16-generic

I often use Kate to process some text with regexp and yesterday caught a bug. After a few manipulations Kate freezes and starts to consume all available memory until hangs whole system or be killed. It seems that the problem in endless loop or recursion happened in regexp processing. I was trying to split a big line to several lines. For that I need to search for ";\*" regexp. But I made a mistake and forgot the escape char. And just when I pressed "Regular expressions" checkbox I got a system freeze due to no free RAM available.

Reproducible: Always

Steps to Reproduce:
1. Open Kate with a new file.
2. Paste following text in it. (Without quotes. This is one line ):
"*(ns_winners+1) = 0x62;*(ns_winners+1) = 0x63;*(ns_winners+1) = 0x66;*(ns_winners+1) = 0x6f;*(ns_winners+1) = 0x70;*(ns_winners+1) = 0x71;*(ns_winners+1) = 0x76;*(ns_winners+1) = 0x78;*(ns_winners+1) = 0x7c;*(ns_winners+1) = 0x8b;*(ns_winners+1) = 0xa0;*(ns_winners+1) = 0xbc;*(ns_winners+1) = 0xbd;*(ns_winners+1) = 0xbe;*(ns_winners+1) = 0xbf;*(ns_winners+1) = 0xc0;*(ns_winners+1) = 0xc1;*(ns_winners+1) = 0xc2;*(ns_winners+1) = 0xc8;*(ns_winners+1) = 0xc9;*(ns_winners+1) = 0xca;*(ns_winners+1) = 0xcb;*(ns_winners+1) = 0xcc;*(ns_winners+1) = 0xcf;*(ns_winners+1) = 0xd0;*(ns_winners+1) = 0xdf;*(ns_winners+1) = 0xe1"
3. Now press Ctr+F to open "search and replace" tab at bottom.
4. Type in ";*" in Find edit box (without quotes). The sequences will highlights with yellow.
5. Open advanced options with button to the left from Find edit box and check the "Regular expressions" checkbox.
The endless memory allocation starts just after step 5.

Actual Results:  
Kate freezes and greedy allocates all available memory.

Expected Results:  
Kate doesn't freeze and display search results (no idea how would they looks like in this case) and not consume all my RAM.

Frankly to say, this is a first time I faced with such problem while working with regexps in Kate for last 2 years. Well, may be second one.
Comment 1 nRoof 2015-12-29 09:16:02 UTC
I can confirm this issue on freshly updated Arch 64-bit with linux-lts-4.1.15-1 kernel.

It can also be reproduced when Regular expression checkbox is checked and Find box contains any single character followed by * or ? 

Example: .*
Another one: 1?

It doesn't matter what text is being edited, the issue exists even in an empty new document.
Comment 2 Dominik Haumann 2016-04-05 19:18:45 UTC
There is definitely something wrong. I get "620 matches found", even though there are just 26...

Needs investigation.
Comment 3 Dominik Haumann 2018-08-15 20:06:54 UTC
So the thing is the following: The string in the bug report is just in one line and contains 620 columns. The regular expression ";*" means match ';' as often as possible. But even an empty string counts as match. So we get 620 matches, just as many characters as we have in the document.
Comment 4 Lothar 2018-12-29 12:38:39 UTC
> Kate freezes and greedy allocates all available memory.

Can't reproduce this now, so the main issue seems to be fixed

Frameworks 5.53.0
Kate 19.03.70
Comment 5 Christoph Cullmann 2019-08-24 20:25:18 UTC
Hmm, I can't reproduce the out-of-memory either.
We fixed some issues with search during this year, thought.