diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs index 9fbfcc9302c562..53f312a5dc250b 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs @@ -58,21 +58,12 @@ internal IntPtr[] GetStackIPs() internal static IntPtr EdiSeparator => (IntPtr)1; // Marks a boundary where an ExceptionDispatchInfo rethrew an exception. - private void AppendStackIP(IntPtr IP, bool isFirstRethrowFrame) + private void AppendStackIP(IntPtr IP) { if (_idxFirstFreeStackTraceEntry == 0) { _corDbgStackTrace = new IntPtr[16]; } - else if (isFirstRethrowFrame) - { - // For the first frame after rethrow, we replace the last entry in the stack trace with the IP - // of the rethrow. This is overwriting the IP of where control left the corresponding try - // region for the catch that is rethrowing. - _corDbgStackTrace[_idxFirstFreeStackTraceEntry - 1] = IP; - return; - } - if (_idxFirstFreeStackTraceEntry >= _corDbgStackTrace.Length) GrowStackTrace(); @@ -133,8 +124,8 @@ private static void AppendExceptionStackFrame(object exceptionObj, IntPtr IP, in // with another OutOfMemoryException, which may lead to infinite recursion. bool fatalOutOfMemory = ex == PreallocatedOutOfMemoryException.Instance; - if (!fatalOutOfMemory) - ex.AppendStackIP(IP, isFirstRethrowFrame); + if (!isFirstRethrowFrame && !fatalOutOfMemory) + ex.AppendStackIP(IP); #if FEATURE_PERFTRACING if (isFirstFrame && NativeRuntimeEventSource.Log.IsEnabled())