Title: [251447] trunk
Revision
251447
Author
[email protected]
Date
2019-10-22 13:27:53 -0700 (Tue, 22 Oct 2019)

Log Message

Fix incorrect assertion in operationRegExpExecNonGlobalOrSticky().
https://bugs.webkit.org/show_bug.cgi?id=203230
<rdar://problem/56460749>

Reviewed by Robin Morisset.

JSTests:

* stress/incorrect-exception-assertion-in-operationRegExpExecNonGlobalOrSticky.js: Added.

Source/_javascript_Core:

operationRegExpExecNonGlobalOrSticky() was asserting no exception when
createRegExpMatchesArray() returns null.  createRegExpMatchesArray() only returns
null when RegExp::matchInline() returns -1.  RegExp::matchInline() can return -1
either when there's an error, or if the match fails.  When there's an error,
RegExp::matchInline() also throws an exception via a throwError() helper.

This patch fixes operationRegExpExecNonGlobalOrSticky() to check for an exception
being thrown, or createRegExpMatchesArray() returning a null array due to a failed
match.

* dfg/DFGOperations.cpp:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (251446 => 251447)


--- trunk/JSTests/ChangeLog	2019-10-22 20:23:24 UTC (rev 251446)
+++ trunk/JSTests/ChangeLog	2019-10-22 20:27:53 UTC (rev 251447)
@@ -1,3 +1,13 @@
+2019-10-22  Mark Lam  <[email protected]>
+
+        Fix incorrect assertion in operationRegExpExecNonGlobalOrSticky().
+        https://bugs.webkit.org/show_bug.cgi?id=203230
+        <rdar://problem/56460749>
+
+        Reviewed by Robin Morisset.
+
+        * stress/incorrect-exception-assertion-in-operationRegExpExecNonGlobalOrSticky.js: Added.
+
 2019-10-21  Mark Lam  <[email protected]>
 
         Rolling out r251411: Fix is incorrect.

Added: trunk/JSTests/stress/incorrect-exception-assertion-in-operationRegExpExecNonGlobalOrSticky.js (0 => 251447)


--- trunk/JSTests/stress/incorrect-exception-assertion-in-operationRegExpExecNonGlobalOrSticky.js	                        (rev 0)
+++ trunk/JSTests/stress/incorrect-exception-assertion-in-operationRegExpExecNonGlobalOrSticky.js	2019-10-22 20:27:53 UTC (rev 251447)
@@ -0,0 +1,26 @@
+//@ runDefault("--alwaysUseShadowChicken=true", "--jitPolicyScale=0", "--useRandomizingFuzzerAgent=1", "--maxPerThreadStackUsage=1572863")
+//@ slow!
+
+class C {
+    constructor(func) {
+        this.func = func;
+    }
+    runTest() {
+        this.func();
+    }
+}
+function recurseAndTest() {
+    try {
+        recurseAndTest();
+        test.runTest();
+    } catch (e) {
+    }
+}
+const howManyParentheses = 1000;
+const deepRE = new RegExp('('.repeat(howManyParentheses) + ')'.repeat(howManyParentheses));
+let test = 
+    new C(() => {
+        deepRE.exec('');
+    });
+
+recurseAndTest();

Modified: trunk/Source/_javascript_Core/ChangeLog (251446 => 251447)


--- trunk/Source/_javascript_Core/ChangeLog	2019-10-22 20:23:24 UTC (rev 251446)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-10-22 20:27:53 UTC (rev 251447)
@@ -1,3 +1,23 @@
+2019-10-22  Mark Lam  <[email protected]>
+
+        Fix incorrect assertion in operationRegExpExecNonGlobalOrSticky().
+        https://bugs.webkit.org/show_bug.cgi?id=203230
+        <rdar://problem/56460749>
+
+        Reviewed by Robin Morisset.
+
+        operationRegExpExecNonGlobalOrSticky() was asserting no exception when
+        createRegExpMatchesArray() returns null.  createRegExpMatchesArray() only returns
+        null when RegExp::matchInline() returns -1.  RegExp::matchInline() can return -1
+        either when there's an error, or if the match fails.  When there's an error,
+        RegExp::matchInline() also throws an exception via a throwError() helper.
+
+        This patch fixes operationRegExpExecNonGlobalOrSticky() to check for an exception
+        being thrown, or createRegExpMatchesArray() returning a null array due to a failed
+        match.
+
+        * dfg/DFGOperations.cpp:
+
 2019-10-22  Adrian Perez de Castro  <[email protected]>
 
         [GTK][WPE] Fix non-unified builds after r251326

Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (251446 => 251447)


--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2019-10-22 20:23:24 UTC (rev 251446)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp	2019-10-22 20:27:53 UTC (rev 251447)
@@ -1341,12 +1341,10 @@
     unsigned lastIndex = 0;
     MatchResult result;
     JSArray* array = createRegExpMatchesArray(vm, globalObject, string, input, regExp, lastIndex, result);
-    if (!array) {
-        ASSERT(!scope.exception());
+    RETURN_IF_EXCEPTION(scope, { });
+    if (!array)
         return JSValue::encode(jsNull());
-    }
 
-    RETURN_IF_EXCEPTION(scope, { });
     globalObject->regExpGlobalData().recordMatch(vm, globalObject, regExp, string, result);
     return JSValue::encode(array);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to