CThreads commit
c225bf9
Description
When joining threads on Windows, the process crashes in the final call to cthreads_thread_detach with exception that the thread handle has already been closed.
Looking at the code, it seems a call to CloseHandle was recently added to cthreads_thread_join:
|
CloseHandle(handle); |
|
|
|
if (code) *(void **)code = (void *)(uintptr_t)exit_code; |
|
|
|
return cthreads_thread_detach(thread); |
However on the final return call through cthreads_thread_detach, the CloseHandle function is called a second time.
Removing line 126 above fixes the problem.
Steps to reproduce
- Compile for windows.
- Create a thread using
cthreads_thread_create with default attributes.
- Have the thread function simply return
- Call
cthreads_thread_join from the main thread.
- Exception occurs.
Example code
No response
Confirmations
CThreads commit
c225bf9
Description
When joining threads on Windows, the process crashes in the final call to
cthreads_thread_detachwith exception that the thread handle has already been closed.Looking at the code, it seems a call to
CloseHandlewas recently added tocthreads_thread_join:CThreads/cthreads.c
Lines 126 to 130 in c225bf9
However on the final return call through
cthreads_thread_detach, theCloseHandlefunction is called a second time.Removing line 126 above fixes the problem.
Steps to reproduce
cthreads_thread_createwith default attributes.cthreads_thread_joinfrom the main thread.Example code
No response
Confirmations