Pali Rohár <[email protected]> wrote:

> On Wednesday 26 August 2026 10:53:28 LIU Hao wrote:
>> 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.

This Microsoft article[1] says that you should _never_ call `CreateThread` from 
`DllMain`:

```
Call CreateThread. Creating a thread can work if you do not synchronize with 
other threads, but it is risky.
```

Given the nature of `_beginthread[ex]` functions, I think this also applies to 
them.

- Kirill Makurin

[1] 
https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices


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

Reply via email to