Search in sources :

Example 96 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class CheckEngine method findRegionForPointer.

private GCHeapRegionDescriptor findRegionForPointer(AbstractPointer pointer, GCHeapRegionDescriptor region) {
    GCHeapRegionDescriptor regionDesc = null;
    if (region != null && region.isAddressInRegion(pointer)) {
        return region;
    }
    regionDesc = regionForAddress(pointer);
    if (null != regionDesc) {
        return regionDesc;
    }
    // TODO kmt : this is tragically slow
    try {
        GCHeapRegionIterator iterator = GCHeapRegionIterator.from();
        while (iterator.hasNext()) {
            regionDesc = GCHeapRegionDescriptor.fromHeapRegionDescriptor(iterator.next());
            if (isPointerInRegion(pointer, regionDesc)) {
                return regionDesc;
            }
        }
    } catch (CorruptDataException e) {
    }
    return null;
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 97 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class CheckEngine method checkClassHeap.

public int checkClassHeap(J9ClassPointer clazz, J9MemorySegmentPointer segment) {
    int result;
    /*
		 * Verify that this is, in fact, a class
		 */
    try {
        result = checkJ9Class(clazz, segment, _cycle.getCheckFlags());
        if (J9MODRON_GCCHK_RC_OK != result) {
            CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", result, _cycle.nextErrorCount());
            _reporter.report(error);
        }
        /*
			 * Process object slots in the class
			 */
        GCClassIterator classIterator = GCClassIterator.fromJ9Class(clazz);
        while (classIterator.hasNext()) {
            PointerPointer slotPtr = PointerPointer.cast(classIterator.nextAddress());
            J9ObjectPointer object = J9ObjectPointer.cast(slotPtr.at(0));
            result = checkObjectIndirect(object);
            if (J9MODRON_GCCHK_RC_OK != result) {
                String elementName = "";
                switch(classIterator.getState()) {
                    case GCClassIterator.state_statics:
                        elementName = "static ";
                        break;
                    case GCClassIterator.state_constant_pool:
                        elementName = "constant ";
                        break;
                    case GCClassIterator.state_slots:
                        elementName = "slots ";
                        break;
                }
                CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
            if (GCExtensions.isStandardGC()) {
                /* If the slot has its old bit OFF, the class's remembered bit should be ON */
                if (object.notNull() && !ObjectModel.isOld(object)) {
                    if (!ObjectModel.isRemembered(clazz.classObject())) {
                        CheckError error = new CheckError(clazz, slotPtr, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REMEMBERED_SET_OLD_OBJECT, _cycle.nextErrorCount());
                        _reporter.report(error);
                        return J9MODRON_SLOT_ITERATOR_OK;
                    }
                }
            }
        }
        if (J9MODRON_GCCHK_RC_OK != checkClassStatics(clazz)) {
            return J9MODRON_SLOT_ITERATOR_OK;
        }
        J9ClassPointer replaced = clazz.replacedClass();
        if (replaced.notNull()) {
            if (!J9ClassHelper.isSwappedOut(replaced)) {
                CheckError error = new CheckError(clazz, clazz.replacedClassEA(), _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_REPLACED_CLASS_HAS_NO_HOTSWAP_FLAG, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
        }
        /*
			 * Process class slots in the class
			 */
        GCClassIteratorClassSlots classIteratorClassSlots = GCClassIteratorClassSlots.fromJ9Class(clazz);
        while (classIteratorClassSlots.hasNext()) {
            PointerPointer classSlotPtr = PointerPointer.cast(classIteratorClassSlots.nextAddress());
            J9ClassPointer classSlot = J9ClassPointer.cast(classSlotPtr.at(0));
            String elementName = "";
            result = J9MODRON_GCCHK_RC_OK;
            switch(classIteratorClassSlots.getState()) {
                case GCClassIteratorClassSlots.state_constant_pool:
                    /* may be NULL */
                    if (classSlot.notNull()) {
                        result = checkJ9ClassPointer(classSlot);
                    }
                    elementName = "constant ";
                    break;
                case GCClassIteratorClassSlots.state_superclasses:
                    /* must not be NULL */
                    result = checkJ9ClassPointer(classSlot);
                    elementName = "superclass ";
                    break;
                case GCClassIteratorClassSlots.state_interfaces:
                    /* must not be NULL */
                    result = checkJ9ClassPointer(classSlot);
                    elementName = "interface ";
                    break;
                case GCClassIteratorClassSlots.state_array_class_slots:
                    /* may be NULL */
                    if (classSlot.notNull()) {
                        result = checkJ9ClassPointer(classSlot);
                    }
                    elementName = "array class ";
            }
            if (J9MODRON_GCCHK_RC_OK != result) {
                CheckError error = new CheckError(clazz, classSlotPtr, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
                _reporter.report(error);
                return J9MODRON_SLOT_ITERATOR_OK;
            }
        }
    } catch (CorruptDataException e) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(clazz, _cycle, _currentCheck, "Class ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
        _reporter.report(error);
    }
    return J9MODRON_SLOT_ITERATOR_OK;
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) GCClassIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassIterator) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) GCClassIteratorClassSlots(com.ibm.j9ddr.vm29.j9.gc.GCClassIteratorClassSlots)

Example 98 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class CheckVMThreadStacks method check.

@Override
public void check() {
    try {
        GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
        while (vmThreadListIterator.hasNext()) {
            J9VMThreadPointer walkThread = vmThreadListIterator.next();
            // GC_VMThreadStackSlotIterator::scanSlots(toScanWalkThread, toScanWalkThread, (void *)&localData, checkStackSlotIterator, false, false);
            WalkState walkState = new WalkState();
            walkState.walkThread = walkThread;
            walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK | J9_STACKWALK_SKIP_INLINES;
            walkState.callBacks = new BaseStackWalkerCallbacks() {

                public void objectSlotWalkFunction(J9VMThreadPointer walkThread, WalkState walkState, PointerPointer objectSlot, VoidPointer stackAddress) {
                    _engine.checkSlotStack(objectSlot, walkThread, stackAddress);
                }
            };
            StackWalker.walkStackFrames(walkState);
        }
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) BaseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 99 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class CheckVMThreadStacks method print.

@Override
public void print() {
    try {
        GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
        final ScanFormatter formatter = new ScanFormatter(this, "thread stacks");
        while (vmThreadListIterator.hasNext()) {
            J9VMThreadPointer walkThread = vmThreadListIterator.next();
            formatter.section("thread slots", walkThread);
            WalkState walkState = new WalkState();
            walkState.walkThread = walkThread;
            walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK | J9_STACKWALK_SKIP_INLINES;
            walkState.callBacks = new BaseStackWalkerCallbacks() {

                public void objectSlotWalkFunction(J9VMThreadPointer walkThread, WalkState walkState, PointerPointer objectSlot, VoidPointer stackAddress) {
                    try {
                        formatter.entry(objectSlot.at(0));
                    } catch (CorruptDataException e) {
                    }
                }
            };
            StackWalker.walkStackFrames(walkState);
            formatter.endSection();
            formatter.section("thread stack", walkThread);
            dumpStackTrace(walkThread);
            formatter.endSection();
        }
        formatter.end("thread stacks");
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) BaseStackWalkerCallbacks(com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 100 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class CheckJNIGlobalReferences method print.

@Override
public void print() {
    try {
        VoidPointer globalRefs = VoidPointer.cast(getJavaVM().jniGlobalReferences());
        GCJNIGlobalReferenceIterator jniGlobalReferenceIterator = GCJNIGlobalReferenceIterator.from();
        ScanFormatter formatter = new ScanFormatter(this, "jniGlobalReferences", globalRefs);
        while (jniGlobalReferenceIterator.hasNext()) {
            J9ObjectPointer slot = jniGlobalReferenceIterator.next();
            if (slot.notNull()) {
                formatter.entry(slot);
            }
        }
        formatter.end("jniGlobalReferences", globalRefs);
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : GCJNIGlobalReferenceIterator(com.ibm.j9ddr.vm29.j9.gc.GCJNIGlobalReferenceIterator) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)221 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)46 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)41 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)33 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)30 NoSuchElementException (java.util.NoSuchElementException)28 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)25 UDATA (com.ibm.j9ddr.vm29.types.UDATA)20 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)17 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)15 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)11 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 PatternString (com.ibm.j9ddr.util.PatternString)7 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)7 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)7