Title: [209590] trunk/Source
Revision
209590
Author
[email protected]
Date
2016-12-08 17:54:31 -0800 (Thu, 08 Dec 2016)

Log Message

Always check the return value of pthread_key_create()
<https://webkit.org/b/165274>

Reviewed by Darin Adler.

Source/bmalloc:

* bmalloc/PerThread.h:
(bmalloc::PerThreadStorage::init): Call BCRASH() if
pthread_key_create() returns an error.  The error code will be
stored in a register available in a crash log, so no need to log
the value explicitly.

Source/WebCore:

* platform/ios/wak/WebCoreThread.mm:
(InitThreadContextKey): Call CRASH() if pthread_key_create()
returns an error.  The error code will be stored in a register
available in a crash log, so no need to log the value
explicitly.

Source/WTF:

* wtf/ThreadIdentifierDataPthreads.cpp:
(WTF::ThreadIdentifierData::initializeOnce): Make the code more
readable by assigning a variable to the result of
pthread_key_create().  This matches the idiom used elsewhere.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (209589 => 209590)


--- trunk/Source/WTF/ChangeLog	2016-12-09 01:51:17 UTC (rev 209589)
+++ trunk/Source/WTF/ChangeLog	2016-12-09 01:54:31 UTC (rev 209590)
@@ -1,3 +1,15 @@
+2016-12-08  David Kilzer  <[email protected]>
+
+        Always check the return value of pthread_key_create()
+        <https://webkit.org/b/165274>
+
+        Reviewed by Darin Adler.
+
+        * wtf/ThreadIdentifierDataPthreads.cpp:
+        (WTF::ThreadIdentifierData::initializeOnce): Make the code more
+        readable by assigning a variable to the result of
+        pthread_key_create().  This matches the idiom used elsewhere.
+
 2016-12-08  Keith Miller  <[email protected]>
 
         Add 64-bit signed LEB decode method

Modified: trunk/Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp (209589 => 209590)


--- trunk/Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp	2016-12-09 01:51:17 UTC (rev 209589)
+++ trunk/Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp	2016-12-09 01:54:31 UTC (rev 209590)
@@ -56,7 +56,8 @@
 
 void ThreadIdentifierData::initializeOnce()
 {
-    if (pthread_key_create(&m_key, destruct))
+    int error = pthread_key_create(&m_key, destruct);
+    if (error)
         CRASH();
 }
 

Modified: trunk/Source/WebCore/ChangeLog (209589 => 209590)


--- trunk/Source/WebCore/ChangeLog	2016-12-09 01:51:17 UTC (rev 209589)
+++ trunk/Source/WebCore/ChangeLog	2016-12-09 01:54:31 UTC (rev 209590)
@@ -1,3 +1,16 @@
+2016-12-08  David Kilzer  <[email protected]>
+
+        Always check the return value of pthread_key_create()
+        <https://webkit.org/b/165274>
+
+        Reviewed by Darin Adler.
+
+        * platform/ios/wak/WebCoreThread.mm:
+        (InitThreadContextKey): Call CRASH() if pthread_key_create()
+        returns an error.  The error code will be stored in a register
+        available in a crash log, so no need to log the value
+        explicitly.
+
 2016-12-08  Alex Christensen  <[email protected]>
 
         Reduce PassRefPtr use in platform/graphics

Modified: trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm (209589 => 209590)


--- trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm	2016-12-09 01:51:17 UTC (rev 209589)
+++ trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm	2016-12-09 01:54:31 UTC (rev 209590)
@@ -620,7 +620,9 @@
 
 static void InitThreadContextKey()
 {
-    pthread_key_create(&threadContextKey, FreeThreadContext);
+    int error = pthread_key_create(&threadContextKey, FreeThreadContext);
+    if (error)
+        CRASH();
 }
 
 static WebThreadContext *CurrentThreadContext(void)

Modified: trunk/Source/bmalloc/ChangeLog (209589 => 209590)


--- trunk/Source/bmalloc/ChangeLog	2016-12-09 01:51:17 UTC (rev 209589)
+++ trunk/Source/bmalloc/ChangeLog	2016-12-09 01:54:31 UTC (rev 209590)
@@ -1,3 +1,16 @@
+2016-12-08  David Kilzer  <[email protected]>
+
+        Always check the return value of pthread_key_create()
+        <https://webkit.org/b/165274>
+
+        Reviewed by Darin Adler.
+
+        * bmalloc/PerThread.h:
+        (bmalloc::PerThreadStorage::init): Call BCRASH() if
+        pthread_key_create() returns an error.  The error code will be
+        stored in a register available in a crash log, so no need to log
+        the value explicitly.
+
 2016-12-06  Alexey Proskuryakov  <[email protected]>
 
         Correct SDKROOT values in xcconfig files

Modified: trunk/Source/bmalloc/bmalloc/PerThread.h (209589 => 209590)


--- trunk/Source/bmalloc/bmalloc/PerThread.h	2016-12-09 01:51:17 UTC (rev 209589)
+++ trunk/Source/bmalloc/bmalloc/PerThread.h	2016-12-09 01:54:31 UTC (rev 209590)
@@ -97,7 +97,9 @@
     static void init(void* object, void (*destructor)(void*))
     {
         std::call_once(s_onceFlag, [destructor]() {
-            pthread_key_create(&s_key, destructor);
+            int error = pthread_key_create(&s_key, destructor);
+            if (error)
+                BCRASH();
             s_didInitialize = true;
         });
         pthread_setspecific(s_key, object);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to