From 610dbc19a4fc3747d5afebb4c94ac77c41f56267 Mon Sep 17 00:00:00 2001 From: Austin Wise Date: Fri, 26 Oct 2018 09:35:09 -0700 Subject: Remove some dead code related to cross-appdomain exceptions. (#20634) --- src/System.Private.CoreLib/src/System/Exception.cs | 29 ++-------------- .../src/System/Threading/Thread.cs | 2 -- src/debug/ee/rcthread.cpp | 11 ------ src/vm/ceemain.cpp | 3 -- src/vm/context.h | 4 --- src/vm/mscorlib.h | 7 ---- src/vm/rexcep.h | 2 -- src/vm/threads.cpp | 39 ---------------------- src/vm/threads.h | 25 -------------- 9 files changed, 2 insertions(+), 120 deletions(-) (limited to 'src') diff --git a/src/System.Private.CoreLib/src/System/Exception.cs b/src/System.Private.CoreLib/src/System/Exception.cs index b451000421..0b1d39f143 100644 --- a/src/System.Private.CoreLib/src/System/Exception.cs +++ b/src/System.Private.CoreLib/src/System/Exception.cs @@ -694,9 +694,8 @@ namespace System // See src\inc\corexcep.h's EXCEPTION_COMPLUS definition: private const int _COMPlusExceptionCode = unchecked((int)0xe0434352); // Win32 exception code for COM+ exceptions - // InternalToString is called by the runtime to get the exception text - // and create a corresponding CrossAppDomainMarshaledException - internal virtual string InternalToString() + // InternalToString is called by the runtime to get the exception text. + internal string InternalToString() { // Get the current stack trace string. return ToString(true, true); @@ -747,29 +746,5 @@ namespace System [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetMessageFromNativeResources(ExceptionMessageKind kind, StringHandleOnStack retMesg); } - - //-------------------------------------------------------------------------- - // Telesto: Telesto doesn't support appdomain marshaling of objects so - // managed exceptions that leak across appdomain boundaries are flatted to - // its ToString() output and rethrown as an CrossAppDomainMarshaledException. - // The Message field is set to the ToString() output of the original exception. - //-------------------------------------------------------------------------- - - internal sealed class CrossAppDomainMarshaledException : SystemException - { - public CrossAppDomainMarshaledException(string message, int errorCode) - : base(message) - { - HResult = errorCode; - } - - // Normally, only Telesto's UEF will see these exceptions. - // This override prints out the original Exception's ToString() - // output and hides the fact that it is wrapped inside another excepton. - internal override string InternalToString() - { - return Message; - } - } } diff --git a/src/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/System.Private.CoreLib/src/System/Threading/Thread.cs index 0fea39c7ef..2c71856344 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -29,8 +29,6 @@ namespace System.Threading using System.Runtime.Versioning; using System.Diagnostics; - internal delegate object InternalCrossContextDelegate(object[] args); - internal class ThreadHelper { private Delegate _start; diff --git a/src/debug/ee/rcthread.cpp b/src/debug/ee/rcthread.cpp index 7ea362451f..2d1b06de2e 100644 --- a/src/debug/ee/rcthread.cpp +++ b/src/debug/ee/rcthread.cpp @@ -1570,17 +1570,6 @@ LExit: dbgOnly_IdentifySpecialEEThread(); #endif - // We commit the thread's entire stack to ensure we're robust in low memory conditions. If we can't commit the - // stack, then we can't let the CLR continue to function. - BOOL fSuccess = Thread::CommitThreadStack(NULL); - - if (!fSuccess) - { - STRESS_LOG0(LF_GC, LL_ALWAYS, "Thread::CommitThreadStack failed.\n"); - _ASSERTE(!"Thread::CommitThreadStack failed."); - EEPOLICY_HANDLE_FATAL_ERROR(COR_E_STACKOVERFLOW); - } - DebuggerRCThread* t = (DebuggerRCThread*)g_pRCThread; t->ThreadProc(); // this thread is local, go and become the helper diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp index 04b12264a8..e961510425 100644 --- a/src/vm/ceemain.cpp +++ b/src/vm/ceemain.cpp @@ -849,9 +849,6 @@ void EEStartupHelper(COINITIEE fFlags) IfFailGo(E_OUTOFMEMORY); } - // Initialize contexts - Context::Initialize(); - g_pEEShutDownEvent = new CLREvent(); g_pEEShutDownEvent->CreateManualEvent(FALSE); diff --git a/src/vm/context.h b/src/vm/context.h index 3c746b647f..e14a1854e5 100644 --- a/src/vm/context.h +++ b/src/vm/context.h @@ -37,10 +37,6 @@ public: return m_pDomain; } - static void Initialize() - { - } - typedef void (*ADCallBackFcnType)(LPVOID); #ifdef DACCESS_COMPILE diff --git a/src/vm/mscorlib.h b/src/vm/mscorlib.h index ab00e94577..d9fb6dabb5 100644 --- a/src/vm/mscorlib.h +++ b/src/vm/mscorlib.h @@ -385,11 +385,6 @@ DEFINE_METHOD(EXCEPTION, TRY_GET_RESTRICTED_LANGUAGE_ERROR_OBJECT, #endif // FEATURE_COMINTEROP -DEFINE_CLASS(CROSSAPPDOMAINMARSHALEDEXCEPTION, System, CrossAppDomainMarshaledException) -DEFINE_METHOD(CROSSAPPDOMAINMARSHALEDEXCEPTION, STR_INT_CTOR, .ctor, IM_Str_Int_RetVoid) - - - DEFINE_CLASS(SYSTEM_EXCEPTION, System, SystemException) DEFINE_METHOD(SYSTEM_EXCEPTION, STR_EX_CTOR, .ctor, IM_Str_Exception_RetVoid) @@ -903,8 +898,6 @@ DEFINE_CLASS(CONTEXTCALLBACK, Threading, ContextCallback) DEFINE_CLASS(STACKCRAWMARK, Threading, StackCrawlMark) #endif -DEFINE_CLASS(CROSS_CONTEXT_DELEGATE, Threading, InternalCrossContextDelegate) - DEFINE_CLASS_U(Threading, Thread, ThreadBaseObject) DEFINE_FIELD_U(m_Name, ThreadBaseObject, m_Name) DEFINE_FIELD_U(m_Delegate, ThreadBaseObject, m_Delegate) diff --git a/src/vm/rexcep.h b/src/vm/rexcep.h index b4a8318d92..9113783d0c 100644 --- a/src/vm/rexcep.h +++ b/src/vm/rexcep.h @@ -300,8 +300,6 @@ DEFINE_EXCEPTION(g_SystemNS, NotImplementedException, false, E DEFINE_EXCEPTION(g_SystemNS, OutOfMemoryException, false, E_OUTOFMEMORY, CTL_E_OUTOFMEMORY, STD_CTL_SCODE(31001)) -DEFINE_EXCEPTION(g_SystemNS, CrossAppDomainMarshaledException, false, E_FAIL) - DEFINE_EXCEPTION(g_SystemNS, ArgumentNullException, false, E_POINTER) diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp index b9395a8bb9..7a638a9c66 100644 --- a/src/vm/threads.cpp +++ b/src/vm/threads.cpp @@ -1814,14 +1814,6 @@ BOOL Thread::InitThread(BOOL fInternal) { ThrowOutOfMemory(); } - - // We commit the thread's entire stack when it enters the runtime to allow us to be reliable in low me - // situtations. See the comments in front of Thread::CommitThreadStack() for mor information. - ret = Thread::CommitThreadStack(this); - if (ret == FALSE) - { - ThrowOutOfMemory(); - } } ret = Thread::AllocateIOCompletionContext(); @@ -1912,15 +1904,6 @@ BOOL Thread::HasStarted(BOOL bRequiresTSL) goto FAILURE; } - // We commit the thread's entire stack when it enters the runtime to allow us to be reliable in low memory - // situtations. See the comments in front of Thread::CommitThreadStack() for mor information. - res = Thread::CommitThreadStack(this); - if (res == FALSE) - { - m_pExceptionDuringStartup = Exception::GetOOMException(); - goto FAILURE; - } - // If any exception happens during HasStarted, we will cache the exception in Thread::m_pExceptionDuringStartup // which will be thrown in Thread.Start as an internal exception EX_TRY @@ -7015,28 +6998,6 @@ __declspec(noinline) void AllocateSomeStack(){ VolatileStore(mem, 0); } - -/* - * CommitThreadStack - * - * Commit the thread's entire stack. A thread's stack is usually only reserved memory, not committed. The OS will - * commit more pages as the thread's stack grows. But, if the system is low on memory and disk space, its possible - * that the OS will not have enough memory to grow the stack. That causes a stack overflow exception at very random - * times, and the CLR can't handle that. - * - * Parameters: - * The Thread object for this thread, if there is one. NULL otherwise. - * - * Returns: - * TRUE if the function succeeded, FALSE otherwise. - */ -/*static*/ -BOOL Thread::CommitThreadStack(Thread* pThreadOptional) -{ - - return TRUE; -} - #ifndef FEATURE_PAL // static // private diff --git a/src/vm/threads.h b/src/vm/threads.h index d736fac6e9..e36e78497a 100644 --- a/src/vm/threads.h +++ b/src/vm/threads.h @@ -2434,30 +2434,9 @@ public: void EnterContextRestricted(Context* c, ContextTransitionFrame* pFrame); void ReturnToContext(ContextTransitionFrame *pFrame); -private: - typedef enum { - RaiseCrossContextSuccess, - RaiseCrossContextRetry, - RaiseCrossContextClassInit - } RaiseCrossContextResult; - - - // The "orBlob" stores the serialized image of a managed Exception object as it gets marshaled - // across AD boundaries. - // - // In Telesto, we don't support true appdomain marshaling so the "orBlob" is in fact an - // agile wrapper object whose ToString() echoes the original exception's ToString(). - typedef OBJECTREF ORBLOBREF; - - RaiseCrossContextResult TryRaiseCrossContextException(Exception **ppExOrig, - Exception *pException, - RuntimeExceptionKind *pKind, - OBJECTREF *ppThrowable, - ORBLOBREF *pOrBlob); public: void DECLSPEC_NORETURN RaiseCrossContextException(Exception* pEx, ContextTransitionFrame* pFrame); - void RaiseCrossContextExceptionHelper(Exception* pEx,ContextTransitionFrame* pFrame); // ClearContext are to be called only during shutdown void ClearContext(); @@ -3626,10 +3605,6 @@ public: // space to restore the guard page, so make sure you know what you're doing when you decide to call this. VOID RestoreGuardPage(); - // Commit the thread's entire stack. Note: this works on managed or unmanaged threads, and pLowerBoundMemInfo - // is optional. - static BOOL CommitThreadStack(Thread* pThreadOptional); - #if defined(FEATURE_HIJACK) && !defined(PLATFORM_UNIX) private: // Redirecting of threads in managed code at suspension -- cgit v1.2.3