⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 246024 in webkit


Ignore:
Timestamp:
Jun 2, 2019, 3:18:06 PM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Crash explicitly if StructureIDs are exhausted
https://bugs.webkit.org/show_bug.cgi?id=198467

Reviewed by Sam Weinig.

When StructureIDTable::m_size reaches to s_maximumNumberOfStructures, newCapacity in resize function is also capped with s_maximumNumberOfStructures.
So m_size == newCapacity. In that case, the following code in resize function, makeFreeListFromRange(m_size, m_capacity - 1); starts executing the
wrong code.

Currently, this is safe. We immediately execute the wrong code in makeFreeListFromRange, and crash with zero division. But we should not rely on
this crash, and instead we should explicitly crash because we exhaust StructureIDs.

This patch inserts RELEASE_ASSERT for m_size < newCapacity status to ensure that resize is always extending the table.

In practice, this crash does not happen in Safari because Safari has memory footprint limit. To exhaust StructureIDs, we need to allocate massive
amount of Structures, and it exceeds the memory footprint limit and the process will be killed.

  • runtime/StructureIDTable.cpp:

(JSC::StructureIDTable::resize):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r246022 r246024  
     12019-06-02  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Crash explicitly if StructureIDs are exhausted
     4        https://bugs.webkit.org/show_bug.cgi?id=198467
     5
     6        Reviewed by Sam Weinig.
     7
     8        When StructureIDTable::m_size reaches to s_maximumNumberOfStructures, newCapacity in resize function is also capped with s_maximumNumberOfStructures.
     9        So m_size == newCapacity. In that case, the following code in resize function, `makeFreeListFromRange(m_size, m_capacity - 1);` starts executing the
     10        wrong code.
     11
     12        Currently, this is safe. We immediately execute the wrong code in makeFreeListFromRange, and crash with zero division. But we should not rely on
     13        this crash, and instead we should explicitly crash because we exhaust StructureIDs.
     14
     15        This patch inserts RELEASE_ASSERT for `m_size < newCapacity` status to ensure that resize is always extending the table.
     16
     17        In practice, this crash does not happen in Safari because Safari has memory footprint limit. To exhaust StructureIDs, we need to allocate massive
     18        amount of Structures, and it exceeds the memory footprint limit and the process will be killed.
     19
     20        * runtime/StructureIDTable.cpp:
     21        (JSC::StructureIDTable::resize):
     22
    1232019-06-02  Keith Miller  <keith_miller@apple.com>
    224
  • trunk/Source/JavaScriptCore/runtime/StructureIDTable.cpp

    r242103 r246024  
    103103        newCapacity = s_maximumNumberOfStructures;
    104104
     105    // If m_size is already s_maximumNumberOfStructures, newCapacity becomes s_maximumNumberOfStructures in the above code.
     106    // In that case, we should crash because of exhaust of StructureIDs.
     107    RELEASE_ASSERT_WITH_MESSAGE(m_size < newCapacity, "Crash intentionally because of exhaust of StructureIDs.");
     108
    105109    // Create the new table.
    106110    auto newTable = makeUniqueArray<StructureOrOffset>(newCapacity);
Note: See TracChangeset for help on using the changeset viewer.