summaryrefslogtreecommitdiff
path: root/src/vm/excep.cpp
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2018-12-10 02:57:57 -0800
committerJan Vorlicek <janvorli@microsoft.com>2018-12-10 11:57:57 +0100
commit49ca3db92a48da71d25c607af9716a30bafb3ff8 (patch)
treeedef4dd6526f291d37ad7dc783b52c124e834634 /src/vm/excep.cpp
parentbc03ef9aeb467950f181a2e2d53fe4b92a98d0c9 (diff)
downloadcoreclr-49ca3db92a48da71d25c607af9716a30bafb3ff8.tar.gz
coreclr-49ca3db92a48da71d25c607af9716a30bafb3ff8.tar.bz2
coreclr-49ca3db92a48da71d25c607af9716a30bafb3ff8.zip
Delete vm/context.* (#21459)
* Delete vm/context.* Leftover from remoting
Diffstat (limited to 'src/vm/excep.cpp')
-rw-r--r--src/vm/excep.cpp253
1 files changed, 0 insertions, 253 deletions
diff --git a/src/vm/excep.cpp b/src/vm/excep.cpp
index 86e771c93c..cbb6be4300 100644
--- a/src/vm/excep.cpp
+++ b/src/vm/excep.cpp
@@ -12043,259 +12043,6 @@ BOOL CEHelper::CanIDispatchTargetHandleException()
#endif // FEATURE_CORRUPTING_EXCEPTIONS
#ifndef DACCESS_COMPILE
-// When a managed thread starts in non-default domain, its callstack looks like below:
-//
-// <ManagedThreadBase_DispatchOuter>
-// <ManagedThreadBase_DispatchMiddle>
-// <ManagedThreadBase_DispatchInner>
-//
-// -- AD transition is here -- ==> Pushes ContextTransitionFrame and has EX_CATCH
-//
-// <ManagedThreadBase_DispatchOuter>
-// <ManagedThreadBase_DispatchMiddle>
-// <ManagedThreadBase_DispatchInner>
-//
-// In CoreCLR, all managed threads spawned will have a stack like this since they all
-// run in non-DefaultDomain. The upper three frames are in default domain and the lower
-// three are in the non-default domain in which the thread was created. Any exception
-// that is unhandled in non-default domain will be caught at AD transition boundary.
-// The transition boundary does the following tasks:
-//
-// 1) Catch any incoming unhandled exception from the non-default domain using EX_CATCH.
-// 2) Marshal the exception object to the return context (i.e. DefaultDomain)
-// 3) Return to the context of DefaultDomain and throw the marshalled exception object there.
-//
-// All this depends upon the EX_CATCH (which is based upon C++ exception handling) being
-// able to catch the exception.
-//
-// However, if a breakpoint exception ia raised and a debugger is not available to handle it,
-// C++'s catch(...) will not be able to catch it, even when compiled with /EHa. For the curious,
-// refer to "FindHandlerForForeignException" function's implementation in the CRT. One of the first
-// things it does is check for breakpoint exception and if it is, it will simply bail out of the
-// process of finding a handler. Thus, EX_CATCH will not be able to catch this exception and we
-// will not be able to transition to the previous AD context.
-//
-// Imagine a thread in non-default domain suffers breakpoint exception. Assuming it will go unhandled,
-// it will reach the OS, which will trigger an unwind. The execution of termination handlers in lower
-// three frames (above) is fine since they are in the same AD as the thread. But when termination
-// handlers in the upper three frames execute, its a case of bad mixup since the thread is in a different
-// AD context than what the frames are expected to be in.
-//
-// Hence, we need a mechanism to transition to the expected AppDomain in case of breakpoint exception.
-// This function supports this mechanism in a generic fashion, i.e., one can use it to transition to
-// any AppDomain, though only up the stack.
-
-BOOL ReturnToPreviousAppDomain()
-{
- STATIC_CONTRACT_GC_NOTRIGGER;
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_MODE_COOPERATIVE;
- STATIC_CONTRACT_SO_TOLERANT;
-
- Thread *pCurThread = GetThread();
- _ASSERTE(pCurThread != NULL);
-
- BOOL fTransitioned = FALSE;
-
- BEGIN_SO_INTOLERANT_CODE_NOTHROW(pCurThread, return FALSE);
-
- // Get the thread's current domain
- AppDomain *pCurDomain = pCurThread->GetDomain();
- _ASSERTE(pCurDomain != NULL);
-
- // Lookup the ContextTransitionFrame for the transition into the current AppDomain.
- Frame *pCtxTransitionFrame = pCurThread->GetFirstTransitionInto(pCurDomain, NULL);
- if (pCtxTransitionFrame == NULL)
- {
- // Since we couldnt find the context transition frame, check if its the default domain.
- // If so, we will set fTransitioned to TRUE since there is no context transition frame
- // setup for the initial entry into the default domain. For all other transitions to it
- // from non-default domains, we will have a context transition frame. We will do a
- // debug-only check to assert this invariant.
- BOOL fIsDefDomain = pCurDomain->IsDefaultDomain();
-#ifdef _DEBUG
- if (fIsDefDomain)
- {
- // Start with the topmost frame and look for a CTX frame until we reach the top of the frame chain.
- // We better not find one since we couldnt find a transition frame to the DefaultDomain.
- Frame *pStartFrame = pCurThread->GetFrame();
- BOOL fFoundCTXFrame = FALSE;
- while ((pStartFrame != NULL) && (pStartFrame != (Frame *)FRAME_TOP))
- {
- if (pStartFrame->GetVTablePtr() == ContextTransitionFrame::GetMethodFrameVPtr())
- {
- fFoundCTXFrame = TRUE;
- break;
- }
-
- // Get the next frame in the chain
- pStartFrame = pStartFrame->PtrNextFrame();
- }
-
- _ASSERTE_MSG(!fFoundCTXFrame, "How come we didnt find the transition frame to DefDomain but found another CTX frame on the frame chain?");
- }
-#endif // _DEBUG
- fTransitioned = fIsDefDomain;
- LOG((LF_EH, LL_INFO100, "ReturnToPreviousAppDomain: Unable to find the transition into the current domain (IsDefaultDomain: %d).\n", fIsDefDomain));
-
- goto done;
- }
-
- // Confirm its the correct type of frame
- _ASSERTE_MSG(pCtxTransitionFrame->GetVTablePtr() == ContextTransitionFrame::GetMethodFrameVPtr(),
- "How come we didn't find context transition frame for this AD transition?");
-
- // Get the topmost Frame
- Frame *pCurFrame;
- pCurFrame = pCurThread->GetFrame();
-
- // <ASSUMPTION>
- //
- // The loop below assumes we are called during an exception unwind since it
- // unwinds the Frames and pops them off the thread.
- //
- // </ASSUMPTION>
- //
- // Clear all the frames until we are at the frame of our interest. If there was a
- // CTX frame between the topmost frame and the AD transition, then we should be able to
- // catch it here as well.
- while((pCurFrame != NULL) && (pCurFrame < pCtxTransitionFrame) &&
- (pCurFrame->GetVTablePtr() != ContextTransitionFrame::GetMethodFrameVPtr()))
- {
- // Invoke exception unwind and pop the frame off
- pCurFrame->ExceptionUnwind();
- pCurFrame->Pop();
- pCurFrame = pCurThread->GetFrame();
- }
-
- // Confirm that we are at the expected Frame.
- _ASSERTE_MSG(((pCurFrame != NULL) &&
- (pCurFrame->GetVTablePtr() == ContextTransitionFrame::GetMethodFrameVPtr()) &&
- (pCurFrame == pCtxTransitionFrame)),
- "How come we are not at the exact context transition frame?");
-
- // Log our context return
- LOG((LF_EH, LL_INFO100, "ReturnToPreviousAppDomain: Returning from AD %d to AD %d\n",
- GetAppDomain()->GetId().m_dwId, pCtxTransitionFrame->GetReturnDomain()->GetId().m_dwId));
-
- // Return to the previous AD context
- pCurThread->ReturnToContext((ContextTransitionFrame *)pCtxTransitionFrame);
-
-#ifdef _DEBUG
- // At this point, the context transition frame would have been popped off by
- // ReturnToContext above.
- pCurFrame = pCurThread->GetFrame();
- _ASSERTE_MSG(pCurFrame != pCtxTransitionFrame, "How come the CTX frame of AD transition is still on the frame chain?");
-#endif // _DEBUG
-
- // Set the flag that we transitioned correctly.
- fTransitioned = TRUE;
-
-done:;
- END_SO_INTOLERANT_CODE;
-
- return fTransitioned;
-}
-
-// This class defines a holder that can be used to return to previous AppDomain incase an exception
-// goes across an AD transition boundary without reverting the active context.
-//
-// Use this holder *after* you have transitioned to the target AD.
-void ReturnToPreviousAppDomainHolder::Init()
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- SO_TOLERANT;
- }
- CONTRACTL_END;
-
- m_fShouldReturnToPreviousAppDomain = TRUE;
- m_pThread = GetThread();
- _ASSERTE(m_pThread != NULL);
-
-#ifdef _DEBUG
- m_pTransitionedToAD = m_pThread->GetDomain();
-#endif // _DEBUG
-}
-
-ReturnToPreviousAppDomainHolder::ReturnToPreviousAppDomainHolder()
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- SO_TOLERANT;
- }
- CONTRACTL_END;
-
- Init();
-}
-
-void ReturnToPreviousAppDomainHolder::ReturnToPreviousAppDomain()
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- SO_TOLERANT;
- // Test your sanity - we should still be in the transitioned-to AD.
- PRECONDITION(m_pThread->GetDomain() == m_pTransitionedToAD);
- }
- CONTRACTL_END;
-
- {
- GCX_COOP();
- ::ReturnToPreviousAppDomain();
- }
-
- // Set the LastThrownObject as NULL since we have returned to a different
- // AD. Maintaining the reference to an object in the "returned-from" AD
- // will prevent the AD from getting unloaded.
- //
- // Setting to NULL does not require us to be in COOP mode.
- m_pThread->SafeSetLastThrownObject(NULL);
-}
-
-ReturnToPreviousAppDomainHolder::~ReturnToPreviousAppDomainHolder()
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- SO_TOLERANT;
- }
- CONTRACTL_END;
-
- if (m_fShouldReturnToPreviousAppDomain)
- {
- ReturnToPreviousAppDomain();
- }
-}
-
-// Reset the flag to indicate that reverting to previous AD is not required anymore.
-// This should be invoked when the call has successfully returned from the target execution context.
-//
-// By default, this flag is TRUE (see the contructor above) to enable automatic context
-// revert incase an exception goes past the transition.
-//
-// END_DOMAIN_TRANSITION_NO_EH_AT_TRANSITION macro uses it. See its implementation in threads.h
-// for usage.
-void ReturnToPreviousAppDomainHolder::SuppressRelease()
-{
- LIMITED_METHOD_CONTRACT;
-
- m_fShouldReturnToPreviousAppDomain = FALSE;
-}
-
-#endif // !DACCESS_COMPILE
-
-#ifndef DACCESS_COMPILE
// This method will deliver the actual exception notification. Its assumed that the caller has done the necessary checks, including
// checking whether the delegate can be invoked for the exception's corruption severity.
void ExceptionNotifications::DeliverExceptionNotification(ExceptionNotificationHandlerType notificationType, OBJECTREF *pDelegate,