From a054254d2448314f1d24ef319b18dfd7a91747f6 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Tue, 19 Feb 2019 20:48:19 -0800 Subject: Early out from vectored exception handler on uninitialized threads (#22702) Fixes #22698 --- src/vm/excep.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/vm/excep.cpp') diff --git a/src/vm/excep.cpp b/src/vm/excep.cpp index 17919701fe..019ec2543d 100644 --- a/src/vm/excep.cpp +++ b/src/vm/excep.cpp @@ -8017,11 +8017,11 @@ LONG WINAPI CLRVectoredExceptionHandlerShim(PEXCEPTION_POINTERS pExceptionInfo) // // WARNING: This function could potentially throw an exception, however it should only // be able to do so when an interop debugger is attached - if(g_pDebugInterface != NULL) + if (g_pDebugInterface != NULL) { - if(g_pDebugInterface->FirstChanceSuspendHijackWorker(pExceptionInfo->ContextRecord, + if (g_pDebugInterface->FirstChanceSuspendHijackWorker(pExceptionInfo->ContextRecord, pExceptionInfo->ExceptionRecord) == EXCEPTION_CONTINUE_EXECUTION) - return EXCEPTION_CONTINUE_EXECUTION; + return EXCEPTION_CONTINUE_EXECUTION; } #endif @@ -8041,6 +8041,12 @@ LONG WINAPI CLRVectoredExceptionHandlerShim(PEXCEPTION_POINTERS pExceptionInfo) } #endif + if (NtCurrentTeb()->ThreadLocalStoragePointer == NULL) + { + // Ignore exceptions early during thread startup before the thread is fully initialized by the OS + return EXCEPTION_CONTINUE_SEARCH; + } + bool bIsGCMarker = false; #ifdef USE_REDIRECT_FOR_GCSTRESS -- cgit v1.2.3