Search in sources :

Example 1 with MM_HeapLinkedFreeHeaderPointer

use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer in project openj9 by eclipse.

the class GCMemoryPoolSplitAddressOrderedList method checkFreeListsImpl.

/* Validates hints and free list entries without needing additional storage for the free list entries */
@Override
public void checkFreeListsImpl() {
    try {
        /* Get free list and hint iterators for self */
        GCFreeListHeapIterator freeEntryIterator = freeListIterator();
        GCHeapLinkedFreeHeader previousFreeEntry = null;
        J9ModronAllocateHintPointer hint = null;
        MM_HeapLinkedFreeHeaderPointer freeEntryFromHint = null;
        /* Needed to return hints in ascending order of free entry address
			 * Here, we convert : iterator -> list -> (sort list) -> iterator */
        @SuppressWarnings("unchecked") List<J9ModronAllocateHintPointer> hints = IteratorHelpers.toList(hintIterator());
        Collections.sort(hints, new Comparator<J9ModronAllocateHintPointer>() {

            public int compare(J9ModronAllocateHintPointer o1, J9ModronAllocateHintPointer o2) {
                try {
                    if (o2.heapFreeHeader().gt(o1.heapFreeHeader())) {
                        return -1;
                    } else if (o2.heapFreeHeader().eq(o1.heapFreeHeader())) {
                        return 0;
                    } else {
                        return 1;
                    }
                } catch (CorruptDataException e) {
                    raiseCorruptDataEvent("corruption detected in allocation hints", e, false);
                }
                throw new UnsupportedOperationException("Unreachable");
            }
        });
        Iterator<J9ModronAllocateHintPointer> allocHintIterator = hints.iterator();
        if (allocHintIterator.hasNext()) {
            hint = allocHintIterator.next();
            freeEntryFromHint = hint.heapFreeHeader();
        }
        while (freeEntryIterator.hasNext()) {
            GCHeapLinkedFreeHeader freeListEntry = freeEntryIterator.next();
            /* Free List Entry(FLE) checks */
            try {
                /* Call the generic check from base class */
                freeEntryCheck(freeListEntry, previousFreeEntry);
                /* Cache the previousFreeEntry for ordering checks */
                previousFreeEntry = freeListEntry;
            } catch (CorruptFreeEntryException e) {
                raiseCorruptDataEvent("Free list corruption detected", e, false);
            } catch (CorruptDataException e) {
                raiseCorruptDataEvent("Corruption detected in free entry", e, false);
            }
            /* Check hint is in Free List */
            MM_HeapLinkedFreeHeaderPointer freeListEntryPointer = freeListEntry.getHeader();
            /* null is the success condition. It indicated that the free entry from the hint was found in the pools free list.
				 * If we find a entry from hint that is less than current free entry in pools list, fail. */
            while ((null != freeEntryFromHint) && freeEntryFromHint.lte(freeListEntryPointer)) {
                if (freeEntryFromHint.lt(freeListEntryPointer)) {
                    throw new CorruptHintException("allocHintFreeEntryCorrupt", hint);
                } else {
                    if (allocHintIterator.hasNext()) {
                        hint = allocHintIterator.next();
                        freeEntryFromHint = hint.heapFreeHeader();
                    } else {
                        freeEntryFromHint = null;
                    }
                }
            }
        }
        /* If the FLE from the hint was never found in the pools FL, it was a bogus entry */
        if (null != freeEntryFromHint) {
            raiseCorruptDataEvent("Hint corruption detected ", new CorruptHintException("allocHintFreeEntryCorrupt", hint), false);
        }
    } catch (CorruptDataException e) {
        raiseCorruptDataEvent("Data corruption detected while validating freelists", e, false);
    }
}
Also used : J9ModronAllocateHintPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer) MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 2 with MM_HeapLinkedFreeHeaderPointer

use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer in project openj9 by eclipse.

the class GCMemoryPoolAddressOrderedList method freeEntryCheck.

private void freeEntryCheck(GCHeapLinkedFreeHeader freeListEntry, GCHeapLinkedFreeHeader previousFreeEntry) throws CorruptFreeEntryException, CorruptDataException {
    /* Checks Standard GC specific parameters */
    MM_HeapLinkedFreeHeaderPointer freeEntryPointer = freeListEntry.getHeader();
    MM_HeapLinkedFreeHeaderPointer previousFreeEntryPointer = MM_HeapLinkedFreeHeaderPointer.NULL;
    /* Generic checks */
    freeEntryCheckGeneric(freeListEntry);
    /* Checks ordering of AOL and SAOL entries */
    if (null != previousFreeEntry) {
        previousFreeEntryPointer = previousFreeEntry.getHeader();
        /* Validate list ordering.
			 * (This is done in GC code at runtime as an assert0 but just in case) */
        if (previousFreeEntryPointer.gte(freeEntryPointer)) {
            throw new CorruptFreeEntryException("invalidOrdering", freeEntryPointer);
        }
    }
    /* Validate size :
		 * Check if size less than 512 / 768 bytes */
    if (freeListEntry.getSize().lt(GCBase.getExtensions().tlhMinimumSize())) {
        throw new CorruptFreeEntryException("sizeFieldInvalid", freeListEntry.getHeader());
    }
}
Also used : MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer)

Example 3 with MM_HeapLinkedFreeHeaderPointer

use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer in project openj9 by eclipse.

the class GCMemoryPool method freeEntryCheckGeneric.

/**
 * Check individual entries. This check is the same for ALL collectors
 * @param freeListEntry A structure to a free entry for all collectors (except Balanced)
 * @throws CorruptFreeEntryException This needs to be caught by a listener to be of any use
 * @return None. This function throws exceptions which are caught by the listener in checkFreeLists()
 */
protected void freeEntryCheckGeneric(GCHeapLinkedFreeHeader freeListEntry) throws CorruptDataException, CorruptFreeEntryException {
    MM_HeapLinkedFreeHeaderPointer freeListEntryAddress = freeListEntry.getHeader();
    UDATA size = freeListEntry.getSize();
    GCHeapRegionDescriptor region = getRegion();
    U8Pointer entryEndingAddressInclusive = U8Pointer.cast(freeListEntry.getHeader()).add(size.sub(1));
    if (freeListEntry.getHeader().isNull()) {
        throw new CorruptFreeEntryException("freeEntryCorrupt", freeListEntryAddress);
    }
    /* Make sure its a multi-slot dead object */
    if (!(ObjectModel.isDeadObject(freeListEntry.getObject()) && !ObjectModel.isSingleSlotDeadObject(freeListEntry.getObject()))) {
        throw new CorruptFreeEntryException("freeEntryCorrupt", freeListEntryAddress);
    }
    /* Self checks */
    if (!region.isAddressInRegion(VoidPointer.cast(freeListEntryAddress))) {
        throw new CorruptFreeEntryException("freeEntryCorrupt", freeListEntryAddress);
    }
    if (!region.isAddressInRegion(VoidPointer.cast(entryEndingAddressInclusive))) {
        throw new CorruptFreeEntryException("sizeFieldInvalid", freeListEntryAddress);
    }
}
Also used : UDATA(com.ibm.j9ddr.vm29.types.UDATA) MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 4 with MM_HeapLinkedFreeHeaderPointer

use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer in project openj9 by eclipse.

the class GCMemoryPoolAddressOrderedList method checkFreeListsImpl.

/* Validates hints and free list entries without needing additional storage for the free list entries */
@Override
public void checkFreeListsImpl() {
    try {
        /* Get free list and hint iterators for self */
        GCFreeListHeapIterator freeEntryIterator = freeListIterator();
        GCHeapLinkedFreeHeader previousFreeEntry = null;
        J9ModronAllocateHintPointer hint = null;
        MM_HeapLinkedFreeHeaderPointer freeEntryFromHint = null;
        /* Needed to return hints in ascending order of free entry address
			 * Here, we convert : iterator -> list -> (sort list) -> iterator */
        @SuppressWarnings("unchecked") List<J9ModronAllocateHintPointer> hints = IteratorHelpers.toList(hintIterator());
        Collections.sort(hints, new Comparator<J9ModronAllocateHintPointer>() {

            public int compare(J9ModronAllocateHintPointer o1, J9ModronAllocateHintPointer o2) {
                try {
                    if (o2.heapFreeHeader().gt(o1.heapFreeHeader())) {
                        return -1;
                    } else if (o2.heapFreeHeader().eq(o1.heapFreeHeader())) {
                        return 0;
                    } else {
                        return 1;
                    }
                } catch (CorruptDataException e) {
                    raiseCorruptDataEvent("Corruption detected in image", e, false);
                    throw new UnsupportedOperationException("Unreachable");
                }
            }
        });
        Iterator<J9ModronAllocateHintPointer> allocHintIterator = hints.iterator();
        if (allocHintIterator.hasNext()) {
            hint = allocHintIterator.next();
            freeEntryFromHint = hint.heapFreeHeader();
        }
        while (freeEntryIterator.hasNext()) {
            GCHeapLinkedFreeHeader freeListEntry = freeEntryIterator.next();
            /* Free List Entry(FLE) checks */
            try {
                /* Call the generic check from base class */
                freeEntryCheck(freeListEntry, previousFreeEntry);
                /* Cache the previousFreeEntry for ordering checks */
                previousFreeEntry = freeListEntry;
            } catch (CorruptFreeEntryException e) {
                raiseCorruptDataEvent("Free list corruption detected", e, false);
            } catch (CorruptDataException e) {
                raiseCorruptDataEvent("Corruption detected in image", e, false);
            }
            /* Check if the hints entry is in the pools free list */
            MM_HeapLinkedFreeHeaderPointer freeListEntryPointer = freeListEntry.getHeader();
            /* null is the success condition. It indicated that the free entry from the hint was found in the pools free list.
				 * If we find a entry from hint that is less than current free entry in pools list, fail. */
            while ((null != freeEntryFromHint) && freeEntryFromHint.lte(freeListEntryPointer)) {
                if (freeEntryFromHint.lt(freeListEntryPointer)) {
                    raiseCorruptDataEvent("Hint corruption detected", new CorruptHintException("allocHintFreeEntryCorrupt", hint), false);
                } else {
                    if (allocHintIterator.hasNext()) {
                        hint = allocHintIterator.next();
                        freeEntryFromHint = hint.heapFreeHeader();
                    } else {
                        freeEntryFromHint = null;
                    }
                }
            }
        }
        /* If the FLE from the hint was never found in the pools FL, it was a bogus entry */
        if (null != freeEntryFromHint) {
            raiseCorruptDataEvent("Hint corruption detected ", new CorruptHintException("allocHintFreeEntryCorrupt", hint), false);
        }
    } catch (CorruptDataException e) {
        raiseCorruptDataEvent("Data corruption detected while validating freelists", e, false);
    }
}
Also used : J9ModronAllocateHintPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer) MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 5 with MM_HeapLinkedFreeHeaderPointer

use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer in project openj9 by eclipse.

the class GCMemoryPoolSplitAddressOrderedList method freeEntryCheck.

private void freeEntryCheck(GCHeapLinkedFreeHeader freeListEntry, GCHeapLinkedFreeHeader previousFreeEntry) throws CorruptFreeEntryException, CorruptDataException {
    /* Checks Standard GC specific parameters */
    MM_HeapLinkedFreeHeaderPointer freeEntryPointer = freeListEntry.getHeader();
    MM_HeapLinkedFreeHeaderPointer previousFreeEntryPointer = MM_HeapLinkedFreeHeaderPointer.NULL;
    freeEntryCheckGeneric(freeListEntry);
    /* Checks ordering of AOL and SAOL entries */
    if (null != previousFreeEntry) {
        previousFreeEntryPointer = previousFreeEntry.getHeader();
        /* Validate list ordering.
			 * (This is done in GC code at runtime as an assert0 but just in case) */
        if (previousFreeEntryPointer.gte(freeEntryPointer)) {
            throw new CorruptFreeEntryException("invalidOrdering", freeEntryPointer);
        }
    }
    /* Validate size :
		 * Check if size less than 512 / 768 bytes */
    if (freeListEntry.getSize().lt(GCBase.getExtensions().tlhMinimumSize())) {
        throw new CorruptFreeEntryException("sizeFieldInvalid", freeListEntry.getHeader());
    }
}
Also used : MM_HeapLinkedFreeHeaderPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer)

Aggregations

MM_HeapLinkedFreeHeaderPointer (com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer)5 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 J9ModronAllocateHintPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ModronAllocateHintPointer)2 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 UDATA (com.ibm.j9ddr.vm29.types.UDATA)1