Is this a bug in regex:content: searching?

Discussion related to "Everything" 1.5 Alpha.
Post Reply
smarthu
Posts: 3
Joined: Sat Jan 27, 2024 3:26 pm

Is this a bug in regex:content: searching?

Post by smarthu »

I am trying the following regex to search txt files across multiple lines:
regex:content:puppy(.|\n)*?big
The test file is attached.

While typing the above text into the search bar, Everything 1.5a crashes.
After I type:
regex:content:puppy(.|\n)
it is fine.
As long as I type the "*", it crashes.

However, if I copy and paste the entire text into the search bar
regex:content:puppy(.|\n)*?big
It doesn't crash, and it finds this file.
Even if I modify the last part, say I change it to "bigge" or "bi", it still finds the file.
And if I change the last part to something that doesn't exist in the file, say "bigs", it doesn't find the file, as expected.
But if I delete the last characters up to "?", it crashes:
regex:content:puppy(.|\n)*

In Everything V1.4.1.969, it doesn't crash.
But, with
regex:content:puppy(.|\n)*?big
I can't find the file.
If I search within a line, then I can find the file:
regex:content:puppy.*shelter
Attachments
test.rar
(742 Bytes) Downloaded 29 times
void
Developer
Posts: 16974
Joined: Fri Oct 16, 2009 11:31 pm

Re: Is this a bug in regex:content: searching?

Post by void »

Thank you for the bug report smarthu,

This is an issue with PCRE.

There's a recursive call to match which causes a stack overflow.

I'm looking into a fix..



For now, please try the following search:

dotall:regex:content:puppy.*
dotall:regex:content:puppy.*?big
regex:content:(?s)puppy.*

dotall:



The issue also applies to Everything 1.4 and earlier.
Please note you need to escape | in Everything 1.4 and earlier.
The following will crash Everything 1.4 and earlier:
regex:content:"puppy(.|\n)*"

Everything 1.5 will eat the |
It does not need to be escaped with double quotes (")
void
Developer
Posts: 16974
Joined: Fri Oct 16, 2009 11:31 pm

Re: Is this a bug in regex:content: searching?

Post by void »

Everything 1.5.0.1367a sets the regex recursion limit to 256.

The theoretical maximum on x64 is about ~512 and ~800 on x86.
This hard limit should prevent Everything from ever reaching these theoretical maximums and blowing up the stack. (crashing)



addcol:regmatch1 regex:content:puppy(.|\n)* should now silently fail instead of crashing.

Please use the following instead:

addcol:regmatch1 dotall:regex:content:puppy(.*)
Post Reply