Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 4ac4fc7

Browse files
brianrobwtgodbe
authored andcommitted
Fix uaf in DestroyThread function. (#15437) (#15444)
Mark thread's buffers as no longer owned before calling Thread::OnThreadTerminate because thread can delete itself in this method.
1 parent 5fc066a commit 4ac4fc7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/vm/threads.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -987,12 +987,6 @@ void DestroyThread(Thread *th)
987987
#endif // _TARGET_X86_
988988
#endif // WIN64EXCEPTIONS
989989

990-
if (g_fEEShutDown == 0)
991-
{
992-
th->SetThreadState(Thread::TS_ReportDead);
993-
th->OnThreadTerminate(FALSE);
994-
}
995-
996990
#ifdef FEATURE_PERFTRACING
997991
// Before the thread dies, mark its buffers as no longer owned
998992
// so that they can be cleaned up after the thread dies.
@@ -1002,6 +996,12 @@ void DestroyThread(Thread *th)
1002996
pBufferList->SetOwnedByThread(false);
1003997
}
1004998
#endif // FEATURE_PERFTRACING
999+
1000+
if (g_fEEShutDown == 0)
1001+
{
1002+
th->SetThreadState(Thread::TS_ReportDead);
1003+
th->OnThreadTerminate(FALSE);
1004+
}
10051005
}
10061006

10071007
//-------------------------------------------------------------------------

0 commit comments

Comments
 (0)