在 2025-11-22 09:24, Pali Rohár 写道:
I'm somehow not able to trigger this issue.On 64-bit Windows 10 system I'm always getting this line which does not trigger Assertion failed: pacific _localtime32(1112524200): sec=0 min=30 hour=3 mday=3 mon=3 year=105 wday=0 yday=92 isdst=1 This output is from 32-bit crtdll, msvcrt, ucrt and 64-bit msvcrt and ucrt builds. I also tested it on the clean evaluation Windows Server 2022 installation and the output is same, the test is passing. Any idea what I could have missed?
This issue can be reproduced with UCRT, so I can build it in Visual Studio, linking against Microsoft debug CRT, and step into UCRT sources.
In C:\Program Files (x86)\Windows Kits\10\Source\10.0.26100.0\ucrt\time there's: int daylight = 0; long dstbias = 0; long timezone = 0; _ERRCHECK(_get_daylight(&daylight)); _ERRCHECK(_get_dstbias (&dstbias )); // <<==== gets DST bias into `dstbias` _ERRCHECK(_get_timezone(&timezone));The offending invocation to `_localtime32()`, which reaches here indirectly, receives a value of 0 in `dstbias`. It should be -3600.
And here's its implementation:
extern "C" errno_t __cdecl _get_dstbias(long* result)
{
_VALIDATE_RETURN_ERRCODE(result != nullptr, EINVAL);
// This variable is correctly inited at startup, so no need to check if
// CRT init finished.
*result = _dstbias.value();
return 0;
}
This comment is incorrect. It seems that the value is not initialized at startup, but by the first call
to `_localtime32()`. If all those calls to `_localtime32()` and `_localtime64()` before the loop are
removed, the assertion will pass.
This might explain why it doesn't fail on your side; maybe you are in that time zone, but otoh I'm not (we don't do DST whatsoever).
And the fact that `_dstbias` is a static object probably means that it's impossible to change the time zone with `putenv("TZ=PST8PDT"); tzset();` once a TZ-aware function has been called.
So the test could be split into three files. -- 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
