Large regex.exec() loop throws `Uncaught InternalError: too much recursion`
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
People
(Reporter: radusamson, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/javascript
|
Details |
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.
Updated•3 years ago
|
Reporter | ||
Comment 1•3 years ago
|
||
Potentially related bug reported and fix in JSC (Safari): https://bugs.webkit.org/show_bug.cgi?id=202882
Comment 2•3 years ago
|
||
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.
Reporter | ||
Comment 3•3 years ago
|
||
Yes it works well in Chrome (and Edge). The script runs in 3-5 seconds.
Reporter | ||
Comment 4•3 years ago
|
||
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.
Updated•3 years ago
|
Description
•