<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - bmalloc::api methods should maintain crash behavior even if bmalloc is disabled internally"
   href="https://bugs.webkit.org/show_bug.cgi?id=159002">159002</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>bmalloc::api methods should maintain crash behavior even if bmalloc is disabled internally
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>bmalloc
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>joepeck&#64;webkit.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>ggaren&#64;apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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-</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>