Pali Rohár <[email protected]> wrote:
>On Tuesday 28 April 2026 18:19:15 Kirill Makurin wrote:
>> 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.

I see; I just confused ctype.h and wctype.h.

> 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.

The are external versions for all `_is*_l` functions, so removing those macros 
should not be an issue. I wanted to suggest doing so, but couldn't find time to 
get to it.

>> 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.
>
> 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).

I agree. Generally, people shouldn't touch undocumented CRT internals, so this 
sounds like the right solution to me.

> 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).

This sounds like a lot of troubles for little or no real benefits.

> 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.

- Kirill Makurin

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

Reply via email to