On Wednesday 26 August 2026 10:53:28 LIU Hao wrote:
> 在 2026-8-23 20:21, Pali Rohár 写道:
> > diff --git a/mingw-w64-crt/misc/_beginthreadex.c 
> > b/mingw-w64-crt/misc/_beginthreadex.c
> > new file mode 100644
> > index 000000000000..dad6eccf97ff
> > --- /dev/null
> > +++ b/mingw-w64-crt/misc/_beginthreadex.c
> > +  if (thread_handle != (uintptr_t)-1) {
> > +    /* Set HANDLE_FLAG_INHERIT and DACL_SECURITY_INFORMATION as soon as 
> > possible. */
> > +    if (inherit_handle)
> > +      SetHandleInformation((HANDLE)thread_handle, HANDLE_FLAG_INHERIT, 
> > HANDLE_FLAG_INHERIT);
> > +    if (dacl_descriptor)
> > +      SetKernelObjectSecurity((HANDLE)thread_handle, 
> > DACL_SECURITY_INFORMATION, dacl_descriptor);
> > +
> > +    /* Wait until the child thread_func started, filled the thread_id_ptr,
> > +     * stopped using our stack variables, including the automatic array of
> > +     * arguments OR the newly spawned child thread crashed/finished.
> 
> This could cause a deadlock if `_beginthreadex` is called inside `DllMain()`.

Ah... that is right. Thread spawned in DllMain does not start its entry
point until the DllMain finishes.


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to