Bug 159002 - bmalloc::api methods should maintain crash behavior even if bmalloc is disabled internally
Summary: bmalloc::api methods should maintain crash behavior even if bmalloc is disabl...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: bmalloc (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-21 15:41 PDT by Joseph Pecoraro
Modified: 2016-06-21 18:32 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-06-21 15:41:39 PDT
Summary:
bmalloc::api methods should maintain crash behavior even if bmalloc is disabled internally

Notes:
bmalloc.h describes a number of methods as crashing on failure:

    // Crashes on failure.
    inline void* malloc(size_t size)

    // Crashes on failure.
    inline void* memalign(size_t alignment, size_t size)

    // Crashes on failure.
    inline void* realloc(void* object, size_t newSize)

However, bmalloc may be disabled internally for a number of reasons, such as running with GuardMalloc:

    bool Environment::computeIsBmallocEnabled()
    {
        if (isMallocEnvironmentVariableSet())
            return false;
        if (isLibgmallocEnabled())
            return false;
        if (isSanitizerEnabled())
            return false;
        return true;
    }

In those cases, it look like the bmalloc::api methods may return nullptr, instead of crashing. Perhaps the fall back to system malloc behaviors should BMALLOC_ASSERT and crash if null to maintain the expected bmalloc behavior.

For example:

    bmalloc/Allocator.cpp
    86-void* Allocator::reallocate(void* object, size_t newSize)
    87-{
    88:    if (!m_isBmallocEnabled)
    89-        return realloc(object, newSize);
    90-
    --
    172-void* Allocator::allocateSlowCase(size_t size)
    173-{
    174:    if (!m_isBmallocEnabled)
    175-        return malloc(size);
    176-