[compiler-rt] [asan][win] Fix CreateThread leak (PR #126738)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 06:45:13 PST 2025
https://github.com/GkvJwa created https://github.com/llvm/llvm-project/pull/126738
Fix #126541
Since ```t->Destroy``` cannot be called after ```start_routine```(When calling standard thread_start in crt), the func is run in advance to avoid memory leaks and remain the same as before.
>From 04e92792339262f4a97e83357db464dec647618c Mon Sep 17 00:00:00 2001
From: GkvJwa <gkvjwa at gmail.com>
Date: Tue, 11 Feb 2025 22:31:12 +0800
Subject: [PATCH] [asan][win] Fix ExitThread leak
---
compiler-rt/lib/asan/asan_win.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/asan/asan_win.cpp b/compiler-rt/lib/asan/asan_win.cpp
index 09a13b11cff1f..d043bb822d2cf 100644
--- a/compiler-rt/lib/asan/asan_win.cpp
+++ b/compiler-rt/lib/asan/asan_win.cpp
@@ -143,9 +143,11 @@ static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
ThreadStartParams params;
t->GetStartData(params);
+ // The ExitThread will end the current thread, causing destroy to be unable to
+ // be called.
+ t->Destroy();
auto res = (*params.start_routine)(params.arg);
- t->Destroy(); // POSIX calls this from TSD destructor.
return res;
}
More information about the llvm-commits
mailing list