On Tuesday 28 April 2026 18:19:15 Kirill Makurin wrote: > Pali Rohár <[email protected]> wrote: > > > So what do you think. It is better idea to completely remove struct > > threadlocaleinfostruct from header files? Or fix it for versioned msvcrt > > libraries? Because current definition in mingw-w64 is really incorrect. > > If I remember correctly, the only place where we ever access _locale_t's > internals are macro versions of wctype.h functions. I think I mentioned to > you that I got segfaults when used those macros with some CRTs.
threadlocaleinfostruct is dereferenced in ctype.h macros _chvalidchk_l and _ischartype_l which are then used for implementing others macros. For example in this way is defined _isalnum_l or _isalpha_l macros which are for public usage. I'm not surprised that it is causing segfaults. Their current definitions are wrong. > IMO, we should remove all accesses to _locale_t's internals; I'm not sure > whether we should keep `struct threadlocaleinfostruct`. I think fixing for > versioned CRTs it possible, but not for msvcrt.dll, where its layout may be > different depending on OS version. > > - Kirill Makurin I slightly prefer complete removal of those structure definitions (letting just declarations without members, so existing code which is taking just pointer to threadlocaleinfostruct can work). Basically for unversioned msvcrt.dll it is probably not possible to write correct definition (unless we reverse engineer it for each windows version and also unless we figure out that definitions across different windows versions are backward compatible). For versioned msvcr* and ucrt it is possible to fix definitions, basically I have already done it in the change referenced in the first email of this thread. _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
