Skip to content

Commit

Permalink
Fix MPAOL inconsist issue between freeBytes and freeList
Browse files Browse the repository at this point in the history
inconsist issue caused by missing to update previous free entry
during elimilating free entry due to card alignment, it would
generate gap between previous and current free entry for
recycleHeapChunk, then cause losing free entries. it could trigger
the assertions of gc allocation for balanced gc case.

 - updated previous free entry for the case
 - additional assertion check in recycleHeapChunk for verifying
 the case -- for debugging only.

Signed-off-by: Lin Hu <linhu@ca.ibm.com>
  • Loading branch information
LinHu2016 committed Sep 10, 2021
1 parent 680b681 commit f481a5d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gc/base/MemoryPoolAddressOrderedList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ MM_MemoryPoolAddressOrderedList::internalAllocate(MM_EnvironmentBase *env, uintp
currentFreeEntry = doFreeEntryAlignmentUpTo(env, currentFreeEntry);
if (NULL == currentFreeEntry) {
currentFreeEntry = (FREE_ENTRY_END == _firstUnalignedFreeEntry) ? NULL : _firstUnalignedFreeEntry;
previousFreeEntry = (FREE_ENTRY_END == _prevFirstUnalignedFreeEntry) ? NULL : _prevFirstUnalignedFreeEntry;
walkCount += 1;
continue;
}
}
Expand Down Expand Up @@ -1352,6 +1354,16 @@ MM_MemoryPoolAddressOrderedList::recycleHeapChunk(
bool const compressed = compressObjectReferences();
Assert_MM_true(addrBase <= addrTop);
Assert_MM_true((NULL == nextFreeEntry) || (addrTop <= nextFreeEntry));
#if defined(DEBUG)
/* confirming there is no gap between previous free entry and addrBase */
MM_HeapLinkedFreeHeader *current = NULL;
if (previousFreeEntry) {
current = previousFreeEntry->getNext(compressed);
} else if (_heapFreeList) {
current = _heapFreeList;
}
Assert_MM_true((current == NULL) || (((uintptr_t)current + current->getSize()) >= (uintptr_t)addrBase));
#endif
if (internalRecycleHeapChunk(addrBase, addrTop, nextFreeEntry)) {
if (previousFreeEntry) {
Assert_MM_true(previousFreeEntry < addrBase);
Expand Down

0 comments on commit f481a5d

Please sign in to comment.