Browse Source

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>
maint
Seija Kijin 2 years ago committed by Junio C Hamano
parent
commit
0006e2e3f1
  1. 2
      compat/win32/pthread.h

2
compat/win32/pthread.h

@ -66,7 +66,7 @@ pthread_t pthread_self(void); @@ -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;

Loading…
Cancel
Save