jamadden / mrab-regex-hg

Automatically exported from code.google.com/p/mrab-regex-hg
0 stars 2 forks source link

Add timeout detection? #134

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In regular expression's world, infinite loop just like a trap.
Especially when the situation is uncontrollable, it's a disaster for system.

To avoid the disaster, do we need timeout detection (or other mechanism) 
provided by RE engine?
It seems only .NET Framework has build-in timeout detection until now.

Original issue reported on code.google.com by animaliz...@gmail.com on 21 Mar 2015 at 2:46

GoogleCodeExporter commented 9 years ago
Usually the problem is not an infinite loop, but 'catastrophic' backtracking.

You could have an infinite loop with "()*", or 'catastrophic' backtracking with 
"(.*)*".

The re module will reject some regexes that could cause a problem, and it also 
performs some checks while matching, but it can still get caught out.

The regex module, on the other hand, is more lenient in what it accepts and it 
performs more checks while matching, so some regexes that take a long time to 
finish when using the re module will be much quicker when using the regex 
module.

Because of those extra checks, I think that it's not necessary to add a 
timeout, but if you come across a regex that takes much too long to finish (for 
example, issue 88 and issue 89), please let me know.

Original comment by re...@mrabarnett.plus.com on 21 Mar 2015 at 4:13