Changeset 207646 in webkit


Ignore:
Timestamp:
Oct 20, 2016, 5:15:31 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

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):

Location:
trunk/Source/bmalloc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r206380 r207646  
     12016-10-20  Mark Lam  <mark.lam@apple.com>
     2
     3        bmalloc api should crash on failure to allocate when !isBmallocEnabled.
     4        https://bugs.webkit.org/show_bug.cgi?id=163766
     5
     6        Reviewed by Keith Miller and Filip Pizlo.
     7
     8        We want to crash in bmalloc on failure to allocate even when !isBmallocEnabled.
     9        This is so that failures to allocate memory will manifest as crashes with a
     10        unique signature (i.e. as a SIGTRAP on release builds, or as a write to illegal
     11        address 0xbbadbeef on debug builds) and the crash will manifest inside bmalloc.
     12        This distinguishes allocation failures from other crashing bugs that manifest as
     13        SIGSEGVs due to random pointer dereferences in the clients of bmalloc.
     14
     15        * bmalloc/Allocator.cpp:
     16        (bmalloc::Allocator::allocateImpl):
     17        (bmalloc::Allocator::reallocate):
     18        (bmalloc::Allocator::allocateSlowCase):
     19
    1202016-09-26  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
    221
  • trunk/Source/bmalloc/bmalloc/Allocator.cpp

    r205462 r207646  
    8181    if (!m_isBmallocEnabled) {
    8282        void* result = nullptr;
    83         if (posix_memalign(&result, alignment, size))
     83        if (posix_memalign(&result, alignment, size)) {
     84            if (crashOnFailure)
     85                BCRASH();
    8486            return nullptr;
     87        }
    8588        return result;
    8689    }
     
    101104void* Allocator::reallocate(void* object, size_t newSize)
    102105{
    103     if (!m_isBmallocEnabled)
    104         return realloc(object, newSize);
     106    if (!m_isBmallocEnabled) {
     107        void* result = realloc(object, newSize);
     108        if (!result)
     109            BCRASH();
     110        return result;
     111    }
    105112
    106113    size_t oldSize = 0;
     
    187194void* Allocator::allocateSlowCase(size_t size)
    188195{
    189     if (!m_isBmallocEnabled)
    190         return malloc(size);
     196    if (!m_isBmallocEnabled) {
     197        void* result = malloc(size);
     198        if (!result)
     199            BCRASH();
     200        return result;
     201    }
    191202
    192203    if (size <= maskSizeClassMax) {
Note: See TracChangeset for help on using the changeset viewer.