在 2026-8-28 09:55, Kirill Makurin 写道:
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.
That's 'should never' and isn't 'shall never'. Because the limitation exists doesn't necessarily mean that a DLL can't create a thread upon `DLL_PROCESS_ATTACH`.
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
