Pali Rohár <[email protected]> wrote: > On Wednesday 07 October 2026 12:58:14 Kirill Makurin wrote: >> After successful call to `thrd_detach`, handle in `thrd_t` structure >> returned by `thed_current` is set to `NULL`, yes. However, any existing >> instance of `thrd_t` for such thread still contains original thread handle >> (e.g. from the original `thrd_create` call), which means call to `thrd_join` >> will not return error. > > That original thread handle is invalidated (closed) by the thrd_detach call. > So trying to use it after that will cause WinAPI error invalid handle. > The thrd_join() will therefore return an error. > > See: https://godbolt.org/z/Ex9KKEM71 > > The example is throwing SEH 3221225480 (0xC0000008 == STATUS_INVALID_HANDLE). > If you comment the #if 1 part for the thrd_join() then it the example > will not throw SEH. I guess that runtime is configured to throw SEH when > invalid handle is used (instead of just returning error via SetLastError()).
Oh, I see. Then it seems pretty nice. For some reason, I did not consider closing the handle for a running thread. - Kirill Makurin _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
