// 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);
[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;
- }
- }
}
using System.Runtime.Versioning;
using System.Diagnostics;
- internal delegate object InternalCrossContextDelegate(object[] args);
-
internal class ThreadHelper
{
private Delegate _start;
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
IfFailGo(E_OUTOFMEMORY);
}
- // Initialize contexts
- Context::Initialize();
-
g_pEEShutDownEvent = new CLREvent();
g_pEEShutDownEvent->CreateManualEvent(FALSE);
return m_pDomain;
}
- static void Initialize()
- {
- }
-
typedef void (*ADCallBackFcnType)(LPVOID);
#ifdef DACCESS_COMPILE
#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)
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)
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)
{
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();
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
VolatileStore<INT8>(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
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();
// 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