Title: [233795] trunk/Source/WTF
Revision
233795
Author
[email protected]
Date
2018-07-13 00:04:11 -0700 (Fri, 13 Jul 2018)

Log Message

Signal.cpp's activeThreads() should only create its ThreadGroup once.
https://bugs.webkit.org/show_bug.cgi?id=187634
<rdar://problem/40662311>

Reviewed by Yusuke Suzuki.

registerThreadForMachExceptionHandling() is relying on the activeThreads()
ThreadGroup being a singleton.

* wtf/threads/Signals.cpp:
(WTF::activeThreads):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (233794 => 233795)


--- trunk/Source/WTF/ChangeLog	2018-07-13 06:22:33 UTC (rev 233794)
+++ trunk/Source/WTF/ChangeLog	2018-07-13 07:04:11 UTC (rev 233795)
@@ -1,3 +1,17 @@
+2018-07-13  Mark Lam  <[email protected]>
+
+        Signal.cpp's activeThreads() should only create its ThreadGroup once.
+        https://bugs.webkit.org/show_bug.cgi?id=187634
+        <rdar://problem/40662311>
+
+        Reviewed by Yusuke Suzuki.
+
+        registerThreadForMachExceptionHandling() is relying on the activeThreads()
+        ThreadGroup being a singleton.
+
+        * wtf/threads/Signals.cpp:
+        (WTF::activeThreads):
+
 2018-07-12  David Kilzer  <[email protected]>
 
         Revert: iOS port should define HAVE_RUNLOOP_TIMER

Modified: trunk/Source/WTF/wtf/threads/Signals.cpp (233794 => 233795)


--- trunk/Source/WTF/wtf/threads/Signals.cpp	2018-07-13 06:22:33 UTC (rev 233794)
+++ trunk/Source/WTF/wtf/threads/Signals.cpp	2018-07-13 07:04:11 UTC (rev 233795)
@@ -209,10 +209,15 @@
     }
 }
 
-inline ThreadGroup& activeThreads()
+static ThreadGroup& activeThreads()
 {
-    static NeverDestroyed<std::shared_ptr<ThreadGroup>> activeThreads { ThreadGroup::create() };
-    return *activeThreads.get();
+    static std::once_flag initializeKey;
+    static ThreadGroup* activeThreadsPtr = nullptr;
+    std::call_once(initializeKey, [&] {
+        static NeverDestroyed<std::shared_ptr<ThreadGroup>> activeThreads { ThreadGroup::create() };
+        activeThreadsPtr = activeThreads.get().get();
+    });
+    return *activeThreadsPtr;
 }
 
 void registerThreadForMachExceptionHandling(Thread& thread)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to