From ae246a61c947106b14df9941a990e90a7d7b0706 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Tue, 19 Feb 2019 20:48:19 -0800 Subject: [PATCH] Early out from vectored exception handler on uninitialized threads (dotnet/coreclr#22702) Fixes dotnet/coreclr#22698 Commit migrated from https://github.com/dotnet/coreclr/commit/a054254d2448314f1d24ef319b18dfd7a91747f6 --- src/coreclr/src/vm/excep.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/coreclr/src/vm/excep.cpp b/src/coreclr/src/vm/excep.cpp index 1791970..019ec25 100644 --- a/src/coreclr/src/vm/excep.cpp +++ b/src/coreclr/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 -- 2.7.4