Title: [250221] releases/WebKitGTK/webkit-2.26
- Revision
- 250221
- Author
- [email protected]
- Date
- 2019-09-23 03:14:29 -0700 (Mon, 23 Sep 2019)
Log Message
Merge r249777 - JSC crashes due to stack overflow while building RegExp
https://bugs.webkit.org/show_bug.cgi?id=201649
Reviewed by Yusuke Suzuki.
JSTests:
New regression test.
* stress/regexp-bol-optimize-out-of-stack.js: Added.
(test):
(catch):
Source/_javascript_Core:
Check for running out of stack when we are optimizing RegExp containing BOL terms or
other deep copying of disjunctions.
* yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::copyDisjunction):
(JSC::Yarr::YarrPatternConstructor::copyTerm):
(JSC::Yarr::YarrPatternConstructor::error):
(JSC::Yarr::YarrPattern::compile):
Modified Paths
Added Paths
Diff
Modified: releases/WebKitGTK/webkit-2.26/JSTests/ChangeLog (250220 => 250221)
--- releases/WebKitGTK/webkit-2.26/JSTests/ChangeLog 2019-09-23 10:14:26 UTC (rev 250220)
+++ releases/WebKitGTK/webkit-2.26/JSTests/ChangeLog 2019-09-23 10:14:29 UTC (rev 250221)
@@ -1,3 +1,16 @@
+2019-09-10 Michael Saboff <[email protected]>
+
+ JSC crashes due to stack overflow while building RegExp
+ https://bugs.webkit.org/show_bug.cgi?id=201649
+
+ Reviewed by Yusuke Suzuki.
+
+ New regression test.
+
+ * stress/regexp-bol-optimize-out-of-stack.js: Added.
+ (test):
+ (catch):
+
2019-08-30 Yusuke Suzuki <[email protected]>
[JSC] Generate new.target register only when it is used
Added: releases/WebKitGTK/webkit-2.26/JSTests/stress/regexp-bol-optimize-out-of-stack.js (0 => 250221)
--- releases/WebKitGTK/webkit-2.26/JSTests/stress/regexp-bol-optimize-out-of-stack.js (rev 0)
+++ releases/WebKitGTK/webkit-2.26/JSTests/stress/regexp-bol-optimize-out-of-stack.js 2019-09-23 10:14:29 UTC (rev 250221)
@@ -0,0 +1,16 @@
+// This test that the beginning of line (bol) optimization throws when we run out of stack space.
+
+let expectedException = "SyntaxError: Invalid regular _expression_: regular _expression_ too large";
+
+function test()
+{
+ let source = Array(50000).join("(") + /(?:^|:|,)(?:\s*\[)+/g.toString() + Array(50000).join(")");
+ RegExp(source);
+}
+
+try {
+ test();
+} catch(e) {
+ if (e != expectedException)
+ throw "Expected \"" + expectedException + "\" exception, but got \"" + e + "\"";
+}
Modified: releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/ChangeLog (250220 => 250221)
--- releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/ChangeLog 2019-09-23 10:14:26 UTC (rev 250220)
+++ releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/ChangeLog 2019-09-23 10:14:29 UTC (rev 250221)
@@ -1,3 +1,19 @@
+2019-09-11 Michael Saboff <[email protected]>
+
+ JSC crashes due to stack overflow while building RegExp
+ https://bugs.webkit.org/show_bug.cgi?id=201649
+
+ Reviewed by Yusuke Suzuki.
+
+ Check for running out of stack when we are optimizing RegExp containing BOL terms or
+ other deep copying of disjunctions.
+
+ * yarr/YarrPattern.cpp:
+ (JSC::Yarr::YarrPatternConstructor::copyDisjunction):
+ (JSC::Yarr::YarrPatternConstructor::copyTerm):
+ (JSC::Yarr::YarrPatternConstructor::error):
+ (JSC::Yarr::YarrPattern::compile):
+
2019-09-03 Devin Rousso <[email protected]>
REGRESSION (r249078): Flaky crash in com.apple._javascript_Core: Inspector::InjectedScriptModule::ensureInjected
Modified: releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/yarr/YarrPattern.cpp (250220 => 250221)
--- releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/yarr/YarrPattern.cpp 2019-09-23 10:14:26 UTC (rev 250220)
+++ releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/yarr/YarrPattern.cpp 2019-09-23 10:14:29 UTC (rev 250221)
@@ -702,6 +702,11 @@
// skip alternatives with m_startsWithBOL set true.
PatternDisjunction* copyDisjunction(PatternDisjunction* disjunction, bool filterStartsWithBOL = false)
{
+ if (UNLIKELY(!isSafeToRecurse())) {
+ m_error = ErrorCode::PatternTooLarge;
+ return 0;
+ }
+
std::unique_ptr<PatternDisjunction> newDisjunction;
for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) {
PatternAlternative* alternative = disjunction->m_alternatives[alt].get();
@@ -717,6 +722,11 @@
}
}
+ if (hasError(error())) {
+ newDisjunction = 0;
+ return 0;
+ }
+
if (!newDisjunction)
return 0;
@@ -727,6 +737,11 @@
PatternTerm copyTerm(PatternTerm& term, bool filterStartsWithBOL = false)
{
+ if (UNLIKELY(!isSafeToRecurse())) {
+ m_error = ErrorCode::PatternTooLarge;
+ return PatternTerm(term);
+ }
+
if ((term.type != PatternTerm::TypeParenthesesSubpattern) && (term.type != PatternTerm::TypeParentheticalAssertion))
return PatternTerm(term);
@@ -1100,6 +1115,8 @@
}
}
+ ErrorCode error() { return m_error; }
+
private:
bool isSafeToRecurse() const
{
@@ -1116,6 +1133,7 @@
CharacterClassConstructor m_characterClassConstructor;
Vector<String> m_unmatchedNamedForwardReferences;
void* m_stackLimit;
+ ErrorCode m_error { ErrorCode::NoError };
bool m_invertCharacterClass;
bool m_invertParentheticalAssertion { false };
};
@@ -1151,6 +1169,9 @@
constructor.optimizeDotStarWrappedExpressions();
constructor.optimizeBOL();
+ if (hasError(constructor.error()))
+ return constructor.error();
+
{
ErrorCode error = constructor.setupOffsets();
if (hasError(error))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes