RFR: 8255239: The timezone of the hs_err_pid log file is corrupted in Japanese locale

Ioi Lam iklam at openjdk.java.net
Tue Nov 3 16:47:55 UTC 2020


On Tue, 3 Nov 2020 15:26:53 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> Please review this simple fix by using the wide char version of strftime, i.e. wcsftime, to convert the timezone into a wide character string. After that, converting the wide character string back to multi-byte string before printing out the time and timezone.
>> 
>> Testing: ran the test case in the bug report manually on:
>> 
>> - Windows with ja, zh-tw, and en locales;
>> 
>> - Linux and Mac OS with en locale.
>
> src/hotspot/share/runtime/os.cpp line 1006:
> 
>> 1004:   if (localtime_pd(&tloc, &tz) != NULL) {
>> 1005:     wchar_t w_buf[80];
>> 1006:     size_t n = ::wcsftime(w_buf, 80, L"%Z", &tz);
> 
> According to https://linux.die.net/man/3/wcsftime: "The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux."
> 
> Also, the L"%Z" notation is Windows-specific.
> 
> Maybe we should use the new code only on Windows?
> 
> An alternative is to use the C++ standard library (std::wcsftime and std:: wcstombs). However, this part of std:: is not yet permitted -- see https://bugs.openjdk.java.net/browse/JDK-8208089

After further investigation -- wcsftime is in C99. Also, we use it here only inside `if (localtime_pd(&tloc, &tz) != NULL)`. I supposed any Linux distro that has a minimal of locale support to make that function return non-null would have a working implementation of wcsftime.

So I think this code is OK. The only change I request is to change ` L"%Z"` to `"%Z"`

-------------

PR: https://git.openjdk.java.net/jdk/pull/1023


More information about the hotspot-runtime-dev mailing list