Title: [281405] branches/safari-607-branch/Source/WTF
Revision
281405
Author
[email protected]
Date
2021-08-22 10:25:02 -0700 (Sun, 22 Aug 2021)

Log Message

Cherry-pick r242732. rdar://problem/82218742

    Crash under WebCore::IDBDatabase::connectionToServerLost
    https://bugs.webkit.org/show_bug.cgi?id=195563
    <rdar://problem/37193655>

    CrossThreadTask should protect callee if it is ThreadSafeRefCounted.

    Reviewed by Geoffrey Garen.

    * wtf/CrossThreadTask.h:
    (WTF::createCrossThreadTask):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242732 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WTF/ChangeLog (281404 => 281405)


--- branches/safari-607-branch/Source/WTF/ChangeLog	2021-08-22 17:22:05 UTC (rev 281404)
+++ branches/safari-607-branch/Source/WTF/ChangeLog	2021-08-22 17:25:02 UTC (rev 281405)
@@ -1,3 +1,34 @@
+2021-08-22  Kocsen Chung  <[email protected]>
+
+        Cherry-pick r242732. rdar://problem/82218742
+
+    Crash under WebCore::IDBDatabase::connectionToServerLost
+    https://bugs.webkit.org/show_bug.cgi?id=195563
+    <rdar://problem/37193655>
+    
+    CrossThreadTask should protect callee if it is ThreadSafeRefCounted.
+    
+    Reviewed by Geoffrey Garen.
+    
+    * wtf/CrossThreadTask.h:
+    (WTF::createCrossThreadTask):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-03-11  Sihui Liu  <[email protected]>
+
+            Crash under WebCore::IDBDatabase::connectionToServerLost
+            https://bugs.webkit.org/show_bug.cgi?id=195563
+            <rdar://problem/37193655>
+
+            CrossThreadTask should protect callee if it is ThreadSafeRefCounted.
+
+            Reviewed by Geoffrey Garen.
+
+            * wtf/CrossThreadTask.h:
+            (WTF::createCrossThreadTask):
+
 2019-07-01  Alan Coon  <[email protected]>
 
         Cherry-pick r244621. rdar://problem/52492610

Modified: branches/safari-607-branch/Source/WTF/wtf/CrossThreadTask.h (281404 => 281405)


--- branches/safari-607-branch/Source/WTF/wtf/CrossThreadTask.h	2021-08-22 17:22:05 UTC (rev 281404)
+++ branches/safari-607-branch/Source/WTF/wtf/CrossThreadTask.h	2021-08-22 17:25:02 UTC (rev 281405)
@@ -27,7 +27,9 @@
 
 #include <wtf/CrossThreadCopier.h>
 #include <wtf/Function.h>
+#include <wtf/RefPtr.h>
 #include <wtf/StdLibExtras.h>
+#include <wtf/ThreadSafeRefCounted.h>
 
 namespace WTF {
 
@@ -82,9 +84,17 @@
     callMemberFunctionForCrossThreadTaskImpl(object, function, std::forward<ArgsTuple>(args), ArgsIndicies());
 }
 
-template<typename T, typename... Parameters, typename... Arguments>
+template<typename T, typename std::enable_if<std::is_base_of<ThreadSafeRefCounted<T>, T>::value, int>::type = 0, typename... Parameters, typename... Arguments>
 CrossThreadTask createCrossThreadTask(T& callee, void (T::*method)(Parameters...), const Arguments&... arguments)
 {
+    return CrossThreadTask([callee = makeRefPtr(&callee), method, arguments = std::make_tuple(crossThreadCopy<Arguments>(arguments)...)]() mutable {
+        callMemberFunctionForCrossThreadTask(callee.get(), method, WTFMove(arguments));
+    });
+}
+
+template<typename T, typename std::enable_if<!std::is_base_of<ThreadSafeRefCounted<T>, T>::value, int>::type = 0, typename... Parameters, typename... Arguments>
+CrossThreadTask createCrossThreadTask(T& callee, void (T::*method)(Parameters...), const Arguments&... arguments)
+{
     return CrossThreadTask([callee = &callee, method, arguments = std::make_tuple(crossThreadCopy<Arguments>(arguments)...)]() mutable {
         callMemberFunctionForCrossThreadTask(callee, method, WTFMove(arguments));
     });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to