示例#1
0
        public static void RhThrowHwEx(uint exceptionCode, ref ExInfo exInfo)
        {
            // trigger a GC (only if gcstress) to ensure we can stackwalk at this point
            GCStress.TriggerGC();

            InternalCalls.RhpValidateExInfoStack();

            IntPtr faultingCodeAddress = exInfo._pExContext->IP;
            bool   instructionFault    = true;

            ExceptionIDs exceptionId;

            switch (exceptionCode)
            {
            case (uint)HwExceptionCode.STATUS_REDHAWK_NULL_REFERENCE:
                exceptionId = ExceptionIDs.NullReference;
                break;

            case (uint)HwExceptionCode.STATUS_REDHAWK_WRITE_BARRIER_NULL_REFERENCE:
                // The write barrier where the actual fault happened has been unwound already.
                // The IP of this fault needs to be treated as return address, not as IP of
                // faulting instruction.
                instructionFault = false;
                exceptionId      = ExceptionIDs.NullReference;
                break;

            case (uint)HwExceptionCode.STATUS_DATATYPE_MISALIGNMENT:
                exceptionId = ExceptionIDs.DataMisaligned;
                break;

            // N.B. -- AVs that have a read/write address lower than 64k are already transformed to
            //         HwExceptionCode.REDHAWK_NULL_REFERENCE prior to calling this routine.
            case (uint)HwExceptionCode.STATUS_ACCESS_VIOLATION:
                exceptionId = ExceptionIDs.AccessViolation;
                break;

            case (uint)HwExceptionCode.STATUS_INTEGER_DIVIDE_BY_ZERO:
                exceptionId = ExceptionIDs.DivideByZero;
                break;

            case (uint)HwExceptionCode.STATUS_INTEGER_OVERFLOW:
                exceptionId = ExceptionIDs.Overflow;
                break;

            default:
                // We don't wrap SEH exceptions from foreign code like CLR does, so we believe that we
                // know the complete set of HW faults generated by managed code and do not need to handle
                // this case.
                FailFastViaClasslib(RhFailFastReason.InternalError, null, faultingCodeAddress);
                exceptionId = ExceptionIDs.NullReference;
                break;
            }

            Exception exceptionToThrow = GetClasslibException(exceptionId, faultingCodeAddress);

            exInfo.Init(exceptionToThrow, instructionFault);
            DispatchEx(ref exInfo._frameIter, ref exInfo, MaxTryRegionIdx);
            FallbackFailFast(RhFailFastReason.InternalError, null);
        }
示例#2
0
        public static void RhRethrow(ref ExInfo activeExInfo, ref ExInfo exInfo)
        {
            // trigger a GC (only if gcstress) to ensure we can stackwalk at this point
            GCStress.TriggerGC();

            InternalCalls.RhpValidateExInfoStack();

            // We need to copy the exception object to this stack location because collided unwinds
            // will cause the original stack location to go dead.
            object rethrownException = activeExInfo.ThrownException;

            exInfo.Init(rethrownException, ref activeExInfo);
            DispatchEx(ref exInfo._frameIter, ref exInfo, activeExInfo._idxCurClause);
            FallbackFailFast(RhFailFastReason.InternalError, null);
        }
示例#3
0
        public static void RhRethrow(ref ExInfo activeExInfo, ref ExInfo exInfo)
        {
            // trigger a GC (only if gcstress) to ensure we can stackwalk at this point
            GCStress.TriggerGC();

            InternalCalls.RhpValidateExInfoStack();

            // We need to copy the Exception object to this stack location because collided unwinds will cause
            // the original stack location to go dead.
            Exception rethrownException = activeExInfo.ThrownException;

            exInfo.Init(rethrownException, ref activeExInfo);
            DispatchEx(ref exInfo._frameIter, ref exInfo, activeExInfo._idxCurClause);
            BinderIntrinsics.DebugBreak();
        }
示例#4
0
        public static void RhThrowHwEx(uint exceptionCode, ref ExInfo exInfo)
        {
            // trigger a GC (only if gcstress) to ensure we can stackwalk at this point
            GCStress.TriggerGC();

            InternalCalls.RhpValidateExInfoStack();

            IntPtr faultingCodeAddress = exInfo._pExContext->IP;

            ExceptionIDs exceptionId;

            switch (exceptionCode)
            {
            case (uint)HwExceptionCode.STATUS_REDHAWK_NULL_REFERENCE:
                exceptionId = ExceptionIDs.NullReference;
                break;

            case (uint)HwExceptionCode.STATUS_DATATYPE_MISALIGNMENT:
                exceptionId = ExceptionIDs.DataMisaligned;
                break;

            // N.B. -- AVs that have a read/write address lower than 64k are already transformed to
            //         HwExceptionCode.REDHAWK_NULL_REFERENCE prior to calling this routine.
            case (uint)HwExceptionCode.STATUS_ACCESS_VIOLATION:
                exceptionId = ExceptionIDs.AccessViolation;
                break;

            case (uint)HwExceptionCode.STATUS_INTEGER_DIVIDE_BY_ZERO:
                exceptionId = ExceptionIDs.DivideByZero;
                break;

            default:
                // We don't wrap SEH exceptions from foreign code like CLR does, so we believe that we
                // know the complete set of HW faults generated by managed code and do not need to handle
                // this case.
                FailFastViaClasslib(RhFailFastReason.InternalError, null, faultingCodeAddress);
                exceptionId = ExceptionIDs.NullReference;
                break;
            }

            Exception exceptionToThrow = GetClasslibException(exceptionId, faultingCodeAddress);

            exInfo.Init(exceptionToThrow);
            DispatchEx(ref exInfo._frameIter, ref exInfo, MaxTryRegionIdx);
            BinderIntrinsics.DebugBreak();
        }
示例#5
0
        public static void RhThrowEx(object exceptionObj, ref ExInfo exInfo)
        {
            // trigger a GC (only if gcstress) to ensure we can stackwalk at this point
            GCStress.TriggerGC();

            InternalCalls.RhpValidateExInfoStack();

            // Transform attempted throws of null to a throw of NullReferenceException.
            if (exceptionObj == null)
            {
                IntPtr faultingCodeAddress = exInfo._pExContext->IP;
                exceptionObj = GetClasslibException(ExceptionIDs.NullReference, faultingCodeAddress);
            }

            exInfo.Init(exceptionObj);
            DispatchEx(ref exInfo._frameIter, ref exInfo, MaxTryRegionIdx);
            FallbackFailFast(RhFailFastReason.InternalError, null);
        }