From 6c400b291a5510ac54f8180a06ae72124c8bf642 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 15 Aug 2024 18:59:38 +0200 Subject: [PATCH] [NativeAOT] Fix stack trace iteration over exceptions (#105877) * [NativeAOT] Fix stack trace iteration over exceptions * Remove exclusion for b08944b * Remove code that was trying to counter-balance ApplyReturnAddressAdjustment * Update src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp * Simplify comment --------- Co-authored-by: Jan Kotas --- src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp | 9 +++------ src/tests/issues.targets | 3 --- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp b/src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp index d26e4e68afef1..5cd5b6dcf2872 100644 --- a/src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp +++ b/src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp @@ -811,11 +811,6 @@ PTR_VOID StackFrameIterator::HandleExCollide(PTR_ExInfo pExInfo) // Sync our 'current' ExInfo with the updated state (we may have skipped other dispatches) ResetNextExInfoForSP(m_RegDisplay.GetSP()); - // In case m_ControlPC is pre-adjusted, counteract here, since the caller of this routine - // will apply the adjustment again once we return. If the m_ControlPC is not pre-adjusted, - // this is simply an no-op. - m_ControlPC = m_OriginalControlPC; - m_dwFlags = curFlags; // The iterator has been moved to the "owner frame" (either a parent funclet or the main @@ -1830,7 +1825,9 @@ void StackFrameIterator::PrepareToYieldFrame() ASSERT(m_pInstance->IsManaged(m_ControlPC) || ((m_dwFlags & SkipNativeFrames) == 0 && (m_dwFlags & UnwoundReversePInvoke) != 0)); - if (m_dwFlags & ApplyReturnAddressAdjustment) + // Do not adjust the PC if ExCollide is set. In that case the m_ControlPC was copied from + // another stack frame iterator and it already has a correct value. + if ((m_dwFlags & (ApplyReturnAddressAdjustment | ExCollide)) == ApplyReturnAddressAdjustment) { m_ControlPC = AdjustReturnAddressBackward(m_ControlPC); } diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 078ca36547d11..a0410d57e0b9c 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -1212,9 +1212,6 @@ https://github.com/dotnet/runtime/issues/101363 - - https://github.com/dotnet/runtime/issues/101364 -