Closed Bug 1377105 Opened 7 years ago Closed 7 years ago

Slow irregexp behavior for /^([0-9]*\.?[0-9]+)+\,[0-9]+$/

Categories

(Core :: JavaScript Engine, defect, P5)

54 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1391654

People

(Reporter: glauber.md, Unassigned)

Details

Attachments

(1 file)

Attached image regexpal_ff54_freeze.PNG (deleted) —
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 OPR/46.0.2597.26

Steps to reproduce:

1) access website http://www.regexpal.com/
2) enter the following Regular Expression: 
3) enter the folowing Test String: 000.000.000,000,00


Actual results:

The program freeze, I needed to kill the application.


Expected results:

Do not lock up entire browser (?)
(In reply to glauber.md from comment #0)
> Created attachment 8882154 [details]
> regexpal_ff54_freeze.PNG
> 
> User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
> (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 OPR/46.0.2597.26
> 
> Steps to reproduce:
> 
> 1) access website http://www.regexpal.com/
> 2) enter the following Regular Expression: 
> 3) enter the folowing Test String: 000.000.000,000,00
> 
> 
> Actual results:
> 
> The program freeze, I needed to kill the application.
> 
> 
> Expected results:
> 
> Do not lock up entire browser (?)

The Regular Expression on 'Steps to reproduce - item #2' is: /^([0-9]*\.?[0-9]+)+\,[0-9]+$/

Sorry.
Component: Untriaged → JavaScript Engine
Keywords: hang
Product: Firefox → Core
This seems to be a slow-script and not a hang (and less problematic now that e10s is on by default). I notice that Chrome also suffers on this case. If I start typing about twenty 0s into the test string, I get slow downs spent in the irregexp library.

Profile: https://perfht.ml/2xar2uQ

The regex itself is quite inefficient as written. Replacing with something like /^(\.?[0-9])+\,[0-9]+$/ does not have any perf problems.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: hang
Priority: -- → P5
Summary: Freeze on regexpal.com → Slow irregexp behavior for /^([0-9]*\.?[0-9]+)+\,[0-9]+$/
This is similar to bug 1391654 (and there are probably also older bugs for the same issue). The problem can be reduced to `/(a+)+b/.exec("a".repeat(30))`, which will also take its time due to catastrophic backtracking.
Thanks André. Let's close this as a duplicate. I like your reduced test case.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: