Fix GC stack unwinding issue
authorJan Vorlicek <janvorli@microsoft.com>
Fri, 24 Apr 2015 00:23:07 +0000 (17:23 -0700)
committerJan Vorlicek <janvorli@microsoft.com>
Fri, 24 Apr 2015 00:23:07 +0000 (17:23 -0700)
This change fixes a GC stack unwinding issue when a GC is
triggered in a catch handler that caught a rethrown
exception.
The problem was that we need to propagate the m_fFixupCallerSPForGCReporting
to the new exception tracker created when interleaved exception handling
starts processing a block of managed frames after processing another
block of managed frames followed by a block of native frames.
Without this flag, the m_EnclosingClauseInfoForGCReporting's
caller SP is not updated when the target unwind frame is found and
such an update is needed.

src/vm/exceptionhandling.cpp
src/vm/exceptionhandling.h

index c3399e3..bf3945a 100644 (file)
@@ -3529,6 +3529,7 @@ void ExceptionTracker::PartialTrackerState::Save(const ExceptionTracker* pSource
     m_EHClauseInfo = pSourceTracker->m_EHClauseInfo;
     m_EnclosingClauseInfo = pSourceTracker->m_EnclosingClauseInfo;
     m_EnclosingClauseInfoForGCReporting = pSourceTracker->m_EnclosingClauseInfoForGCReporting;
+    m_fFixupCallerSPForGCReporting = pSourceTracker->m_fFixupCallerSPForGCReporting;
 }
 
 // Restore the state into the target exception tracker
@@ -3542,6 +3543,7 @@ void ExceptionTracker::PartialTrackerState::Restore(ExceptionTracker* pTargetTra
     pTargetTracker->m_EHClauseInfo = m_EHClauseInfo;
     pTargetTracker->m_EnclosingClauseInfo = m_EnclosingClauseInfo;
     pTargetTracker->m_EnclosingClauseInfoForGCReporting = m_EnclosingClauseInfoForGCReporting;
+    pTargetTracker->m_fFixupCallerSPForGCReporting = m_fFixupCallerSPForGCReporting;
 }
 
 //
@@ -6091,6 +6093,8 @@ bool ExceptionTracker::IsInStackRegionUnwoundByCurrentException(CrawlFrame * pCF
     return ExceptionTracker::IsInStackRegionUnwoundBySpecifiedException(pCF, pCurrentTracker);
 }
 
+
+
 // Returns a bool indicating if the specified CrawlFrame has been unwound by any active (e.g. nested) exceptions.
 // 
 // This method uses various fields of the ExceptionTracker data structure to do its work. Since this code runs on the thread
index 820f0d3..c8581e3 100644 (file)
@@ -677,6 +677,7 @@ private: ;
         EHClauseInfo m_EHClauseInfo;
         EnclosingClauseInfo m_EnclosingClauseInfo;
         EnclosingClauseInfo m_EnclosingClauseInfoForGCReporting;
+        bool m_fFixupCallerSPForGCReporting;
 
     public:
         // Save the state of the source exception tracker