"InternalError: too much recursion" when loading a large manifest.json file
Categories
(WebExtensions :: General, defect, P2)
Tracking
(firefox139 fixed)
Tracking | Status | |
---|---|---|
firefox139 | --- | fixed |
People
(Reporter: robwu, Assigned: robwu)
References
Details
(Whiteboard: [addons-jira])
Attachments
(1 file)
STR:
- Create a manifest.json and add a key with many characters. E.g. 10M of
"foo": "X (repeated 10M times)"
- Load it via
about:debugging
Expected:
- The extension should load.
Actual:
- The extension fails to load, with
about:debugging
's UI displaying:
There was an error during the temporary add-on installation.
Error detailstoo much recursion`
- And the error console:
[ACTION FAILED] TEMPORARY_EXTENSION_INSTALL_FAILURE: too much recursion
readJSON/</<@resource://gre/modules/Extension.sys.mjs:1174:25
onStopRequest@resource://gre/modules/NetUtil.sys.mjs:124:18
Updated•7 months ago
|
Assignee | ||
Comment 1•7 months ago
|
||
This issue is caused by the COMMENT_REGEXP
at https://searchfox.org/mozilla-central/rev/222add4dd36e034fa4d0a8b3e4e1ded979599892/toolkit/components/extensions/Extension.sys.mjs#398-411
This regular expression contains a repeating non-capturing group, but with large inputs, the internal implementation seems to recurse to a depth proportional to the string to test.
I tried fixing the COMMENT_REGEXP
regexp to reduce backtracking (beyond what was attempted in bug 1299256), but found that even the simplest of regular expressions can exhaust the stack when a large input is fed. E.g. the following regexp can be used to try and match a string literal: /^"(?:[^"\\\n]|\\.)*"/
, but triggers RangeError when passed '"' + 'x'.repeat(1e7) + '"'
Here is a self-contained test case demonstrating that a repeating non-capturing group can lead to deep recursion depths, and thus trigger an error (in Chromium and Firefox):
/^a(?:[^x]|nevermatch)*/.exec('a' + "b".repeat(1e7) +'c')
Assignee | ||
Comment 2•7 months ago
|
||
Comment 3•7 months ago
|
||
The severity field is not set for this bug.
:zombie, could you have a look please?
For more information, please visit BugBot documentation.
Assignee | ||
Updated•6 months ago
|
Assignee | ||
Updated•6 months ago
|
Comment 4•4 months ago
|
||
There is an r+ patch which didn't land and no activity in this bug for 2 weeks.
:robwu, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.
Updated•4 months ago
|
Assignee | ||
Updated•4 months ago
|
Comment 6•4 months ago
|
||
bugherder |
Description
•