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

Commit ddab65b

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

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
@@ -902,12 +902,6 @@ void DestroyThread(Thread *th)
902902
#endif // _TARGET_X86_
903903
#endif // WIN64EXCEPTIONS
904904

905-
if (g_fEEShutDown == 0)
906-
{
907-
th->SetThreadState(Thread::TS_ReportDead);
908-
th->OnThreadTerminate(FALSE);
909-
}
910-
911905
#ifdef FEATURE_PERFTRACING
912906
// Before the thread dies, mark its buffers as no longer owned
913907
// so that they can be cleaned up after the thread dies.
@@ -917,6 +911,12 @@ void DestroyThread(Thread *th)
917911
pBufferList->SetOwnedByThread(false);
918912
}
919913
#endif // FEATURE_PERFTRACING
914+
915+
if (g_fEEShutDown == 0)
916+
{
917+
th->SetThreadState(Thread::TS_ReportDead);
918+
th->OnThreadTerminate(FALSE);
919+
}
920920
}
921921

922922
//-------------------------------------------------------------------------

0 commit comments

Comments
 (0)