Title: [290516] trunk/Source/_javascript_Core
Revision
290516
Author
[email protected]
Date
2022-02-25 10:53:01 -0800 (Fri, 25 Feb 2022)

Log Message

[JSC] Use DeferTerminationForAWhile in Interpreter::unwind
https://bugs.webkit.org/show_bug.cgi?id=237176

Reviewed by Mark Lam.

Interpreter::unwind calls sanitizeRemoteFunctionException, which would like to create scope (but it
does not have user observable behavior). Problem is that, since it is creating a scope, it can throw
a termination exception. We were using DeferTermination, but destructor of this scope can still set
termination exception, which results in throwing a termination exception for the error handler.

We use DeferTerminationForAWhile in the prologue of the Interpreter::unwind to ensure that this function
will not accept termination exception coming concurrently.

* interpreter/Interpreter.cpp:
(JSC::sanitizeRemoteFunctionException):
(JSC::Interpreter::unwind):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (290515 => 290516)


--- trunk/Source/_javascript_Core/ChangeLog	2022-02-25 18:44:20 UTC (rev 290515)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-02-25 18:53:01 UTC (rev 290516)
@@ -1,3 +1,22 @@
+2022-02-24  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Use DeferTerminationForAWhile in Interpreter::unwind
+        https://bugs.webkit.org/show_bug.cgi?id=237176
+
+        Reviewed by Mark Lam.
+
+        Interpreter::unwind calls sanitizeRemoteFunctionException, which would like to create scope (but it
+        does not have user observable behavior). Problem is that, since it is creating a scope, it can throw
+        a termination exception. We were using DeferTermination, but destructor of this scope can still set
+        termination exception, which results in throwing a termination exception for the error handler.
+
+        We use DeferTerminationForAWhile in the prologue of the Interpreter::unwind to ensure that this function
+        will not accept termination exception coming concurrently.
+
+        * interpreter/Interpreter.cpp:
+        (JSC::sanitizeRemoteFunctionException):
+        (JSC::Interpreter::unwind):
+
 2022-02-25  Patrick Angle  <[email protected]>
 
         Web Inspector: [Cocoa] Split remote inspector message data into smaller chunks for large messages

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (290515 => 290516)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2022-02-25 18:44:20 UTC (rev 290515)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2022-02-25 18:53:01 UTC (rev 290516)
@@ -672,7 +672,7 @@
 // Replace an exception which passes across a marshalling boundary with a TypeError for its handler's global object.
 static void sanitizeRemoteFunctionException(VM& vm, JSRemoteFunction* remoteFunction, Exception* exception)
 {
-    DeferTermination deferScope(vm);
+    ASSERT(vm.traps().isDeferringTermination());
     auto scope = DECLARE_THROW_SCOPE(vm);
     ASSERT(exception);
     ASSERT(!vm.isTerminationException(exception));
@@ -700,6 +700,10 @@
 
 NEVER_INLINE CatchInfo Interpreter::unwind(VM& vm, CallFrame*& callFrame, Exception* exception)
 {
+    // While running Interpreter::unwind, we must not accept concurrently set termination exception,
+    // otherwise, we can end up in a found error handler with a TerminationException, and effectively
+    // "catch" the TerminationException which should not be catchable.
+    DeferTerminationForAWhile deferScope(vm);
     auto scope = DECLARE_CATCH_SCOPE(vm);
 
     ASSERT(reinterpret_cast<void*>(callFrame) != vm.topEntryFrame);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to