Skip to content

Commit ae1ce2f

Browse files
author
Thomas Moore (CHAKRA)
committed
Fix memory leaks detected during shutdown by cleaning up contexts before detection.
1 parent eff645c commit ae1ce2f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

bin/ChakraCore/ChakraCoreDllFunc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ EXTERN_C BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, PVOID pvReserved)
153153
#if defined(CHECK_MEMORY_LEAK) || defined(LEAK_REPORT)
154154
else
155155
{
156+
ThreadBoundThreadContextManager::DestroyAllContexts();
156157
ThreadContext::ReportAndCheckLeaksOnProcessDetach();
157158
}
158159
#endif

lib/Runtime/Base/ThreadBoundThreadContextManager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ void ThreadContextManagerBase::ShutdownThreadContext(
259259
if (deleteThreadContext)
260260
{
261261
AllocationPolicyManager * policyManager = threadContext->IsThreadBound() ? threadContext->GetAllocationPolicyManager() : nullptr;
262+
#if DBG
263+
// An assert can fire in the Recycler dtor if this ThreadContext is destroyed while
264+
// the process is detaching (i.e., all of the other threads have terminated). In this
265+
// case, don't run that assert because all of the other threads were torn down early
266+
// because of WFMO
267+
threadContext->GetRecycler()->SetDisableConcurrentThreadExitedCheck();
268+
#endif
262269
HeapDelete(threadContext);
263270

264271
if (policyManager)

0 commit comments

Comments
 (0)