Open Bug 1722481 Opened 3 years ago Updated 1 year ago

Large regex.exec() loop throws `Uncaught InternalError: too much recursion`

Categories

(Core :: JavaScript Engine, defect, P3)

78 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: radusamson, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

1.14 MB, text/javascript
Details
Attached file ff.js

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36

Steps to reproduce:

Run the code below with large inputs. See attachment script for reproducing the issue:

while (args = regex.exec(text)){
console.log(args);
}

Actual results:

Half way through the parsing it throws: InternalError: too much recursion

Expected results:

It should process all input successfully.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core

Potentially related bug reported and fix in JSC (Safari): https://bugs.webkit.org/show_bug.cgi?id=202882

Component: JavaScript Engine → Untriaged
Product: Core → Firefox

Does this regexp work in Chrome? The regexp engine is shared code between the two browsers, so a regexp that is too big for Firefox is also likely to be too big for Chrome, and there's not much to be done about that beyond improving the regexp.

The Safari bug is unrelated; as noted in that bug, that regular expression worked in all browsers except Safari.

Severity: -- → S3
Component: Untriaged → JavaScript Engine
Priority: -- → P3
Product: Firefox → Core

Yes it works well in Chrome (and Edge). The script runs in 3-5 seconds.

As for improving the Regex, I don't think there is something wrong with the Regex itself, it compiles well in FF and executes in linear time against smaller than ~400k characters inputs.
This bug might have to do with the input handling more than the Regex.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: