Title: [207981] releases/WebKitGTK/webkit-2.14/Source/bmalloc
Revision
207981
Author
[email protected]
Date
2016-10-27 03:22:04 -0700 (Thu, 27 Oct 2016)

Log Message

Merge r207646 - bmalloc api should crash on failure to allocate when !isBmallocEnabled.
https://bugs.webkit.org/show_bug.cgi?id=163766

Reviewed by Keith Miller and Filip Pizlo.

We want to crash in bmalloc on failure to allocate even when !isBmallocEnabled.
This is so that failures to allocate memory will manifest as crashes with a
unique signature (i.e. as a SIGTRAP on release builds, or as a write to illegal
address 0xbbadbeef on debug builds) and the crash will manifest inside bmalloc.
This distinguishes allocation failures from other crashing bugs that manifest as
SIGSEGVs due to random pointer dereferences in the clients of bmalloc.

* bmalloc/Allocator.cpp:
(bmalloc::Allocator::allocateImpl):
(bmalloc::Allocator::reallocate):
(bmalloc::Allocator::allocateSlowCase):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/bmalloc/ChangeLog (207980 => 207981)


--- releases/WebKitGTK/webkit-2.14/Source/bmalloc/ChangeLog	2016-10-27 10:19:51 UTC (rev 207980)
+++ releases/WebKitGTK/webkit-2.14/Source/bmalloc/ChangeLog	2016-10-27 10:22:04 UTC (rev 207981)
@@ -1,3 +1,22 @@
+2016-10-20  Mark Lam  <[email protected]>
+
+        bmalloc api should crash on failure to allocate when !isBmallocEnabled.
+        https://bugs.webkit.org/show_bug.cgi?id=163766
+
+        Reviewed by Keith Miller and Filip Pizlo.
+
+        We want to crash in bmalloc on failure to allocate even when !isBmallocEnabled.
+        This is so that failures to allocate memory will manifest as crashes with a
+        unique signature (i.e. as a SIGTRAP on release builds, or as a write to illegal
+        address 0xbbadbeef on debug builds) and the crash will manifest inside bmalloc.
+        This distinguishes allocation failures from other crashing bugs that manifest as
+        SIGSEGVs due to random pointer dereferences in the clients of bmalloc.
+
+        * bmalloc/Allocator.cpp:
+        (bmalloc::Allocator::allocateImpl):
+        (bmalloc::Allocator::reallocate):
+        (bmalloc::Allocator::allocateSlowCase):
+
 2016-09-26  Yoshiaki Jitsukawa  <[email protected]>
 
         Avoid implicit conversion from iterator to pointer

Modified: releases/WebKitGTK/webkit-2.14/Source/bmalloc/bmalloc/Allocator.cpp (207980 => 207981)


--- releases/WebKitGTK/webkit-2.14/Source/bmalloc/bmalloc/Allocator.cpp	2016-10-27 10:19:51 UTC (rev 207980)
+++ releases/WebKitGTK/webkit-2.14/Source/bmalloc/bmalloc/Allocator.cpp	2016-10-27 10:22:04 UTC (rev 207981)
@@ -80,8 +80,11 @@
 
     if (!m_isBmallocEnabled) {
         void* result = nullptr;
-        if (posix_memalign(&result, alignment, size))
+        if (posix_memalign(&result, alignment, size)) {
+            if (crashOnFailure)
+                BCRASH();
             return nullptr;
+        }
         return result;
     }
 
@@ -100,8 +103,12 @@
 
 void* Allocator::reallocate(void* object, size_t newSize)
 {
-    if (!m_isBmallocEnabled)
-        return realloc(object, newSize);
+    if (!m_isBmallocEnabled) {
+        void* result = realloc(object, newSize);
+        if (!result)
+            BCRASH();
+        return result;
+    }
 
     size_t oldSize = 0;
     switch (objectType(object)) {
@@ -186,8 +193,12 @@
 
 void* Allocator::allocateSlowCase(size_t size)
 {
-    if (!m_isBmallocEnabled)
-        return malloc(size);
+    if (!m_isBmallocEnabled) {
+        void* result = malloc(size);
+        if (!result)
+            BCRASH();
+        return result;
+    }
 
     if (size <= maskSizeClassMax) {
         size_t sizeClass = bmalloc::maskSizeClass(size);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to