Named capture groups left undefined after OOM in RegExpShared::initializeNamedCaptures
Categories
(Core :: JavaScript Engine, defect, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox78 | --- | fixed |
People
(Reporter: anba, Assigned: iain)
References
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
Test case:
var i = 0;
oomTest(function() {
for (var j = 0; j < 20; ++j) {
var r = RegExp(`(?<_${(i++).toString(32)}a>)`);
try { var e = r.exec("a"); } catch {}
if (e && e.groups === undefined) print("bad groups");
try { var e = r.exec("a"); } catch {}
if (e && e.groups === undefined) print("bad groups");
}
});
Expected:
- Doesn't print "bad groups"
Actual:
- Prints "bad groups"
This happens after OOM in RegExpShared::initializeNamedCaptures
: RegExpShared::kind_
is already set to RegExpShared::Kind::RegExp
by the earlier call to RegExpShared::useRegExpMatch
, so we don't try to recompile the pattern to compute the groups
for the second exec
call.
Comment 1•5 years ago
|
||
Iain, could take a look at this bug.
Assignee | ||
Comment 2•5 years ago
|
||
If we throw an OOM in initializeNamedCaptures for a RegExpShared, we will set kind to RegExp, but not initialize the named captures data. If we recover from the OOM and then execute the same regexp, the cached RegExpShared will not be reparsed, and we won't create named captures for it.
The fix is to reorder CompilePattern so that we only change the state of the RegExpShared after all of the initialization has succeeded. initializeNamedCaptures already avoids this problem by saving the updates until the end.
Depends on D76956
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 4•5 years ago
|
||
Backed out for build bustages on bug1640479.js.
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=303990415&repo=autoland&lineNumber=45367
Backout: https://hg.mozilla.org/integration/autoland/rev/9a6631a07b7552cd81314c955c38d1f1f2276dee
Reporter | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 5•5 years ago
|
||
Forgot to make the testcase conditional on oomTest being defined.
Comment 7•4 years ago
|
||
bugherder |
Description
•