WorkQueue::concurrentApply() passes a raw pointer to a temporary String to Thread...
authorsaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2019 22:01:07 +0000 (22:01 +0000)
committersaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2019 22:01:07 +0000 (22:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191350

Reviewed by Brent Fulgham.

The non COCOA version of WorkQueue::concurrentApply() creates a temporary
String for the threadName and passes the raw pointer of this String to
Thread::create(). After freeing this String, Thread::entryPoint() uses
the raw char pointer to internally initialize the thread.

The fix is to use a single literal string for all the threads' names since
they are created for a thread-pool.

* wtf/WorkQueue.cpp:
(WTF::WorkQueue::concurrentApply):

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

Source/WTF/ChangeLog
Source/WTF/wtf/WorkQueue.cpp

index 609cebe..c4f4e70 100644 (file)
@@ -1,3 +1,21 @@
+2019-01-11  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        WorkQueue::concurrentApply() passes a raw pointer to a temporary String to Thread::create().
+        https://bugs.webkit.org/show_bug.cgi?id=191350
+
+        Reviewed by Brent Fulgham.
+
+        The non COCOA version of WorkQueue::concurrentApply() creates a temporary
+        String for the threadName and passes the raw pointer of this String to
+        Thread::create(). After freeing this String, Thread::entryPoint() uses
+        the raw char pointer to internally initialize the thread.
+
+        The fix is to use a single literal string for all the threads' names since
+        they are created for a thread-pool.
+
+        * wtf/WorkQueue.cpp:
+        (WTF::WorkQueue::concurrentApply):
+
 2019-01-11  Dominik Infuehr  <dinfuehr@igalia.com>
 
         Enable DFG on ARM/Linux again
index e40577c..0535eef 100644 (file)
@@ -75,7 +75,7 @@ void WorkQueue::concurrentApply(size_t iterations, WTF::Function<void (size_t in
 
             m_workers.reserveInitialCapacity(threadCount);
             for (unsigned i = 0; i < threadCount; ++i) {
-                m_workers.append(Thread::create(String::format("ThreadPool Worker %u", i).utf8().data(), [this] {
+                m_workers.append(Thread::create("ThreadPool Worker", [this] {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                     threadBody();
                 }));
             }