From 83bbabab6b992596a13522234c9e6b55d0dcbcfe Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Fri, 3 Apr 2020 13:39:35 +0200 Subject: [PATCH] Fix two issues detected by Valgrind (#34462) * Fix two issues detected by Valgrind When I have used Valgrind to investigate a memory corruption issue recently, I've noticed that it has also reported two cases when a conditional jump was using an uninitialized variable as one of the inputs to the condition. This change fixes these. --- src/coreclr/src/vm/threads.cpp | 4 ++++ src/coreclr/src/vm/win32threadpool.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/coreclr/src/vm/threads.cpp b/src/coreclr/src/vm/threads.cpp index ea35e58..2a22f89 100644 --- a/src/coreclr/src/vm/threads.cpp +++ b/src/coreclr/src/vm/threads.cpp @@ -1539,6 +1539,10 @@ Thread::Thread() m_DeserializationTracker = NULL; m_currentPrepareCodeConfig = nullptr; + +#ifdef _DEBUG + memset(dangerousObjRefs, 0, sizeof(dangerousObjRefs)); +#endif // _DEBUG } //-------------------------------------------------------------------- diff --git a/src/coreclr/src/vm/win32threadpool.cpp b/src/coreclr/src/vm/win32threadpool.cpp index b50cf6b..3d5ec4c 100644 --- a/src/coreclr/src/vm/win32threadpool.cpp +++ b/src/coreclr/src/vm/win32threadpool.cpp @@ -4119,6 +4119,8 @@ DWORD WINAPI ThreadpoolMgr::GateThreadStart(LPVOID lpArgs) GetCPUBusyTime_NT(&prevCPUInfo); #else // !TARGET_UNIX PAL_IOCP_CPU_INFORMATION prevCPUInfo; + memset(&prevCPUInfo, 0, sizeof(prevCPUInfo)); + GetCPUBusyTime_NT(&prevCPUInfo); // ignore return value the first time #endif // !TARGET_UNIX -- 2.7.4