Title: [284861] trunk/Source/WebCore
Revision
284861
Author
you...@apple.com
Date
2021-10-26 02:46:30 -0700 (Tue, 26 Oct 2021)

Log Message

Beef up worker termination handling in ReadableStream routines
https://bugs.webkit.org/show_bug.cgi?id=231500
<rdar://83687915>

Reviewed by Darin Adler.

Add some termination/exception checks after getting values from global objects.
Covered by existing tests.

* bindings/js/ReadableStream.cpp:
(WebCore::ReadableStream::create):
(WebCore::ReadableStream::lock):
* bindings/js/ReadableStreamDefaultController.cpp:
(WebCore::invokeReadableStreamDefaultControllerFunction):
(WebCore::ReadableStreamDefaultController::enqueue):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (284860 => 284861)


--- trunk/Source/WebCore/ChangeLog	2021-10-26 09:17:13 UTC (rev 284860)
+++ trunk/Source/WebCore/ChangeLog	2021-10-26 09:46:30 UTC (rev 284861)
@@ -1,5 +1,23 @@
 2021-10-26  Youenn Fablet  <you...@apple.com>
 
+        Beef up worker termination handling in ReadableStream routines
+        https://bugs.webkit.org/show_bug.cgi?id=231500
+        <rdar://83687915>
+
+        Reviewed by Darin Adler.
+
+        Add some termination/exception checks after getting values from global objects.
+        Covered by existing tests.
+
+        * bindings/js/ReadableStream.cpp:
+        (WebCore::ReadableStream::create):
+        (WebCore::ReadableStream::lock):
+        * bindings/js/ReadableStreamDefaultController.cpp:
+        (WebCore::invokeReadableStreamDefaultControllerFunction):
+        (WebCore::ReadableStreamDefaultController::enqueue):
+
+2021-10-26  Youenn Fablet  <you...@apple.com>
+
         Decrease WebRTC latency by pulling data more often
         https://bugs.webkit.org/show_bug.cgi?id=232143
 

Modified: trunk/Source/WebCore/bindings/js/ReadableStream.cpp (284860 => 284861)


--- trunk/Source/WebCore/bindings/js/ReadableStream.cpp	2021-10-26 09:17:13 UTC (rev 284860)
+++ trunk/Source/WebCore/bindings/js/ReadableStream.cpp	2021-10-26 09:46:30 UTC (rev 284861)
@@ -46,6 +46,7 @@
     auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
 
     auto* constructor = JSC::asObject(globalObject.get(&lexicalGlobalObject, clientData.builtinNames().ReadableStreamPrivateName()));
+    RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
 
     auto constructData = getConstructData(vm, constructor);
     ASSERT(constructData.type != CallData::Type::None);
@@ -115,13 +116,14 @@
 {
     auto& lexicalGlobalObject = *m_globalObject;
     auto& vm = lexicalGlobalObject.vm();
-#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     auto scope = DECLARE_CATCH_SCOPE(vm);
-#endif
 
     auto& clientData = *static_cast<JSVMClientData*>(vm.clientData);
 
     auto* constructor = JSC::asObject(m_globalObject->get(&lexicalGlobalObject, clientData.builtinNames().ReadableStreamDefaultReaderPrivateName()));
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+    if (scope.exception())
+        return;
 
     auto constructData = getConstructData(vm, constructor);
     ASSERT(constructData.type != CallData::Type::None);

Modified: trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp (284860 => 284861)


--- trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp	2021-10-26 09:17:13 UTC (rev 284860)
+++ trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp	2021-10-26 09:46:30 UTC (rev 284861)
@@ -44,10 +44,14 @@
     JSC::VM& vm = lexicalGlobalObject.vm();
     JSC::JSLockHolder lock(vm);
 
+    auto scope = DECLARE_CATCH_SCOPE(vm);
     auto function = lexicalGlobalObject.get(&lexicalGlobalObject, identifier);
+
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+    RETURN_IF_EXCEPTION(scope, false);
+
     ASSERT(function.isCallable(lexicalGlobalObject.vm()));
 
-    auto scope = DECLARE_CATCH_SCOPE(vm);
     auto callData = JSC::getCallData(vm, function);
     call(&lexicalGlobalObject, function, callData, JSC::jsUndefined(), arguments);
     EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
@@ -120,10 +124,8 @@
     auto chunk = JSC::Uint8Array::create(WTFMove(buffer), 0, length);
     auto value = toJS(&lexicalGlobalObject, &lexicalGlobalObject, chunk.get());
 
-    if (UNLIKELY(scope.exception())) {
-        ASSERT(vm.hasPendingTerminationException());
-        return false;
-    }
+    EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+    RETURN_IF_EXCEPTION(scope, false);
 
     return enqueue(value);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to