Ignore:
Timestamp:
Oct 4, 2006, 6:07:49 PM (19 years ago)
Author:
ggaren
Message:

Patch by Darin and me, reviewed by Maciej.

Fixed <rdar://problem/4518397> REGRESSION(?): Oft-seen but unrepro crash

in JavaScript garbage collection (KJS::Collector::collect())

<rdar://problem/4752492> Crash in KJS::collect


The issue here was allocating one garbage-collected object in the midst
of allocating a second garbage-collected object. In such a case, the
zeroIfFree word lies.

  • kjs/collector.cpp: (KJS::Collector::allocate): (KJS::Collector::collect):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/collector.cpp

    r16614 r16797  
    119119  size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect;
    120120  size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect;
     121
    121122  if (numNewObjects >= ALLOCATIONS_PER_COLLECTION && numNewObjects >= numLiveObjectsAtLastCollect) {
    122123    collect();
     
    493494          imp->m_marked = false;
    494495        } else if (currentThreadIsMainThread || imp->m_destructorIsThreadSafe) {
     496          // special case for allocated but uninitialized object
     497          // (We don't need this check earlier because nothing prior this point assumes the object has a valid vptr.)
     498          if (cell->u.freeCell.zeroIfFree == 0)
     499            continue;
     500
    495501          imp->~JSCell();
    496502          --usedCells;
     
    505511    } else {
    506512      size_t minimumCellsToProcess = usedCells;
    507       for (size_t i = 0; i < minimumCellsToProcess; i++) {
     513      for (size_t i = 0; (i < minimumCellsToProcess) & (i < CELLS_PER_BLOCK); i++) {
    508514        CollectorCell *cell = curBlock->cells + i;
    509515        if (cell->u.freeCell.zeroIfFree == 0) {
Note: See TracChangeset for help on using the changeset viewer.