Ignore:
Timestamp:
Jan 19, 2010, 12:39:04 AM (15 years ago)
Author:
[email protected]
Message:

JavaScriptCore: REGRESSION (52082): Crash on worker thread when reloading http://radnan.public.iastate.edu/procedural/
https://bugs.webkit.org/show_bug.cgi?id=33826

Reviewed by Oliver Hunt.

This bug was caused by a GC-protected object being destroyed early by
Heap::destroy. Clients of the GC protect APIs (reasonably) expect pointers
to GC-protected memory to be valid.

The solution is to do two passes of tear-down in Heap::destroy. The first
pass tears down all unprotected objects. The second pass ASSERTs that all
previously protected objects are now unprotected, and then tears down
all perviously protected objects. These two passes simulate the two passes
that would have been required to free a protected object during normal GC.

  • API/JSContextRef.cpp: Removed some ASSERTs that have moved into Heap.
  • runtime/Collector.cpp:

(JSC::Heap::destroy): Moved ASSERTs to here.
(JSC::Heap::freeBlock): Tidied up the use of didShrink by moving its
setter to the function that does the shrinking.
(JSC::Heap::freeBlocks): Implemented above algorithm.
(JSC::Heap::shrinkBlocks): Tidied up the use of didShrink.

WebCore: REGRESSION (52082): Crash on worker thread when reloading http://radnan.public.iastate.edu/procedural/
https://bugs.webkit.org/show_bug.cgi?id=33826

Reviewed by Oliver Hunt.

Test: fast/workers/worker-gc2.html

  • bindings/js/WorkerScriptController.cpp:

(WebCore::WorkerScriptController::~WorkerScriptController): Removed some
ASSERTs that have moved to JavaScriptCore.

LayoutTests: REGRESSION (52082): Crash on worker thread when reloading http://radnan.public.iastate.edu/procedural/
https://bugs.webkit.org/show_bug.cgi?id=33826

Reviewed by Oliver Hunt.

Added a test for this edge case.

  • fast/workers/resources/worker-gc2.js: Added.

(Dummy):

  • fast/workers/worker-gc2.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r53459 r53460  
    187187        return;
    188188
     189    ASSERT(!m_globalData->dynamicGlobalObject);
     190    ASSERT(!isBusy());
     191   
    189192    // The global object is not GC protected at this point, so sweeping may delete it
    190193    // (and thus the global data) before other objects that may use the global data.
     
    291294NEVER_INLINE void Heap::freeBlock(size_t block)
    292295{
     296    m_heap.didShrink = true;
     297
    293298    ObjectIterator it(m_heap, block);
    294299    ObjectIterator end(m_heap, block + 1);
     
    330335void Heap::freeBlocks()
    331336{
    332     while (m_heap.usedBlocks)
    333         freeBlock(0);
     337    ProtectCountSet protectedValuesCopy = m_protectedValues;
     338
     339    clearMarkBits();
     340    markProtectedObjects(m_globalData->markStack);
     341
     342    m_heap.nextCell = 0;
     343    m_heap.nextBlock = 0;
     344    DeadObjectIterator it(m_heap, m_heap.nextBlock, m_heap.nextCell);
     345    DeadObjectIterator end(m_heap, m_heap.usedBlocks);
     346    for ( ; it != end; ++it)
     347        (*it)->~JSCell();
     348
     349    ASSERT(!protectedObjectCount());
     350
     351    ProtectCountSet::iterator protectedValuesEnd = protectedValuesCopy.end();
     352    for (ProtectCountSet::iterator protectedValuesIt = protectedValuesCopy.begin(); protectedValuesIt != protectedValuesEnd; ++protectedValuesIt)
     353        protectedValuesIt->first->~JSCell();
     354
     355    for (size_t block = 0; block < m_heap.usedBlocks; ++block)
     356        freeBlockPtr(m_heap.blocks[block]);
     357
    334358    fastFree(m_heap.blocks);
     359
    335360    memset(&m_heap, 0, sizeof(CollectorHeap));
    336361}
     
    441466        if (m_heap.blocks[i]->marked.isEmpty()) {
    442467            freeBlock(i);
    443             m_heap.didShrink = true;
    444468        } else
    445469            ++i;
Note: See TracChangeset for help on using the changeset viewer.