]> git.ipfire.org Git - thirdparty/git.git/commitdiff
win32: use _endthreadex to terminate threads, not ExitThread
authorSeija Kijin <doremylover123@gmail.com>
Sun, 25 Dec 2022 01:41:50 +0000 (01:41 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 25 Dec 2022 07:34:03 +0000 (16:34 +0900)
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>
compat/win32/pthread.h

index 737983d00bae9190e6a328ccf9a2b1a4914fa109..cc3221cb2c8a84a454784c7fa0dc287dbad83983 100644 (file)
@@ -66,7 +66,7 @@ pthread_t pthread_self(void);
 
 static inline void NORETURN pthread_exit(void *ret)
 {
-       ExitThread((DWORD)(intptr_t)ret);
+       _endthreadex((unsigned)(uintptr_t)ret);
 }
 
 typedef DWORD pthread_key_t;