RFR: 8348323: Corrupted timezone string in JVM crash log
Amit Kumar
amitkumar at openjdk.org
Sat Jan 25 11:13:50 UTC 2025
On Sat, 25 Jan 2025 09:56:45 GMT, Kevin Walls <kevinw at openjdk.org> wrote:
> When we look at this kind of thing in future it will be no timezone printed that means we have hit an existing problem fetching a valid timezone.
Just a thought, can't use this logic to make it more clear ? :
diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp
index 094d68e1a84..aea9aee5adf 100644
--- a/src/hotspot/share/runtime/os.cpp
+++ b/src/hotspot/share/runtime/os.cpp
@@ -1213,8 +1213,12 @@ void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) {
wchar_t w_buf[80];
size_t n = ::wcsftime(w_buf, 80, L"%Z", &tz);
if (n > 0) {
- ::wcstombs(buf, w_buf, buflen);
- st->print("Time: %s %s", timestring, buf);
+ bool success = (::wcstombs(buf, w_buf, buflen) != (size_t)-1);
+ if (success) {
+ st->print("Time: %s %s", timestring, buf);
+ } else {
+ st->print("Time: %s (Error: Failed to convert timezone to multi-byte string)", timestring);
+ }
} else {
st->print("Time: %s", timestring);
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23246#issuecomment-2613930724
More information about the hotspot-runtime-dev
mailing list