]> git.99rst.org Git - git.git/commitdiff
win32: use _endthreadex to terminate threads, not ExitThread
authorSeija Kijin <redacted>
Sun, 25 Dec 2022 01:41:50 +0000 (01:41 +0000)
committerJunio C Hamano <redacted>
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 <redacted>
Acked-by: Johannes Sixt <redacted>
Signed-off-by: Junio C Hamano <redacted>
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;
git clone https://git.99rst.org/PROJECT