win32: use _endthreadex to terminate threads, not ExitThread
Because we use the C runtime and use _beginthreadex to create pthreads, pthread_exit MUST use _endthreadex. Otherwise, according to Microsoft: "Failure to do so results in small memory leaks when the thread calls ExitThread." Simply put, this is not the same as ExitThread. Signed-off-by: Seija Kijin <doremylover123@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Seija Kijin committed
Dec 25, 2022 at 01:41 UTC
0006e2e3f1de6a3a5351da298ee52b5d936addfd
1 file changed
+1
-1
compat/win32/pthread.h
+1
-1
@@ -66,7 +66,7 @@ pthread_t pthread_self(void);
66
67
static inline void NORETURN pthread_exit(void *ret)
68
{
69
- ExitThread((DWORD)(intptr_t)ret);
69
+ _endthreadex((unsigned)(uintptr_t)ret);
70
}
71
72
typedef DWORD pthread_key_t;