在 2026-8-28 11:23, Kirill Makurin 写道:
Unlike `CreateThread`, functions `_beginthread[ex]` also initialize CRT's per-thread state. Documentation[1] for `CreateThread` explicitly tells that if a thread calls any CRT function, it must instead call `_beginthread[ex]`. Pali can tell more about it, as he looked at it more closely.
The thread-local CRT state is initialized on demand; see https://devblogs.microsoft.com/oldnewthing/20171115-00/?p=97405.
(Consider: what happens if a thread which was created by DLL X which was linked MSVCR80.DLL later calls into DLL Y which was linked against MSVCR90.DLL?)
The per-thread state is freed in the entry point callback of a CRT DLL, which explains why there may be a resource leak if the CRT is linked statically; but that doesn't apply to mingw-w64.
-- 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
