JDK-2172901 : -XX:+PrintGCDateStamps is using mt-unsafe localtime function
  • Type: Backport
  • Backport of: JDK-6800586
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2009-02-09
  • Updated: 2012-10-13
  • Resolved: 2009-03-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 Other
6u13-rev b04Fixed hs15Fixed
Comments
SUGGESTED FIX --- src/os/linux/vm/os_linux.cpp- Mon Nov 17 13:02:36 2008 +++ src/os/linux/vm/os_linux.cpp Fri Feb 13 08:48:41 2009 @@ -1,10 +1,10 @@ #ifdef USE_PRAGMA_IDENT_SRC -#pragma ident "@(#)os_linux.cpp 1.263 08/06/25 13:21:22 JVM" +#pragma ident "@(#)os_linux.cpp 1.264 09/02/13 08:59:15 JVM" #endif /* - * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -1419,10 +1419,14 @@ t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec); return buf; } +struct tm* os::localtime_pd(const time_t* clock, struct tm* res) { + return localtime_r(clock, res); +} + //////////////////////////////////////////////////////////////////////////////// // runtime exit support // Note: os::shutdown() might be called very early during initialization, or // called from signal handler. Before adding something to os::shutdown(), make --- src/os/solaris/vm/os_solaris.cpp- Wed Jan 7 17:47:18 2009 +++ src/os/solaris/vm/os_solaris.cpp Fri Feb 13 08:48:45 2009 @@ -1,10 +1,10 @@ #ifdef USE_PRAGMA_IDENT_SRC -#pragma ident "@(#)os_solaris.cpp 1.403 08/12/12 14:24:02 JVM" +#pragma ident "@(#)os_solaris.cpp 1.404 09/02/13 08:59:20 JVM" #endif /* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -317,10 +317,14 @@ address base = current_stack_base(); address bottom = (address)align_size_up((intptr_t)(base - size), os::vm_page_size());; return (size_t)(base - bottom); } +struct tm* os::localtime_pd(const time_t* clock, struct tm* res) { + return localtime_r(clock, res); +} + // interruptible infrastructure // setup_interruptible saves the thread state before going into an // interruptible system call. // The saved state is used to restore the thread to --- src/os/windows/vm/os_windows.cpp- Mon Nov 17 13:02:37 2008 +++ src/os/windows/vm/os_windows.cpp Fri Feb 13 08:48:51 2009 @@ -1,10 +1,10 @@ #ifdef USE_PRAGMA_IDENT_SRC -#pragma ident "@(#)os_windows.cpp 1.535 07/11/15 10:56:43 JVM" +#pragma ident "@(#)os_windows.cpp 1.536 09/02/13 08:59:25 JVM" #endif /* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -328,10 +328,18 @@ VirtualQuery(&minfo, &minfo, sizeof(minfo)); sz = (size_t)os::current_stack_base() - (size_t)minfo.AllocationBase; return sz; } +struct tm* os::localtime_pd(const time_t* clock, struct tm* res) { + const struct tm* time_struct_ptr = localtime(clock); + if (time_struct_ptr != NULL) { + *res = *time_struct_ptr; + return res; + } + return NULL; +} LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo); // Thread start routine for all new Java threads static unsigned __stdcall java_start(Thread* thread) { --- src/share/vm/runtime/os.cpp- Mon Nov 17 13:02:45 2008 +++ src/share/vm/runtime/os.cpp Fri Feb 13 12:22:01 2009 @@ -1,10 +1,10 @@ #ifdef USE_PRAGMA_IDENT_SRC -#pragma ident "@(#)os.cpp 1.185 07/10/04 10:49:22 JVM" +#pragma ident "@(#)os.cpp 1.187 09/02/13 12:31:23 JVM" #endif /* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -146,17 +146,15 @@ const time_t seconds_since_19700101 = milliseconds_since_19700101 / milliseconds_per_microsecond; const int milliseconds_after_second = milliseconds_since_19700101 % milliseconds_per_microsecond; // Convert the time value to a tm and timezone variable - const struct tm *time_struct_temp = localtime(&seconds_since_19700101); - if (time_struct_temp == NULL) { - assert(false, "Failed localtime"); + struct tm time_struct; + if (localtime_pd(&seconds_since_19700101, &time_struct) == NULL) { + assert(false, "Failed localtime_pd"); return NULL; } - // Save the results of localtime - const struct tm time_struct = *time_struct_temp; const time_t zone = timezone; // If daylight savings time is in effect, // we are 1 hour East of our time zone const time_t seconds_per_minute = 60; @@ -165,14 +163,14 @@ time_t UTC_to_local = zone; if (time_struct.tm_isdst > 0) { UTC_to_local = UTC_to_local - seconds_per_hour; } // Compute the time zone offset. - // localtime(3C) sets timezone to the difference (in seconds) + // localtime_pd sets timezone to the difference (in seconds) // between UTC and and local time. // ISO 8601 says we need the difference between local time and UTC, - // we change the sign of the localtime(3C) result. + // we change the sign of the localtime_pd result. const time_t local_to_UTC = -(UTC_to_local); // Then we have to figure out if if we are ahead (+) or behind (-) UTC. char sign_local_to_UTC = '+'; time_t abs_local_to_UTC = local_to_UTC; if (local_to_UTC < 0) { --- src/share/vm/runtime/os.hpp- Mon Nov 17 13:02:45 2008 +++ src/share/vm/runtime/os.hpp Fri Feb 13 08:48:56 2009 @@ -1,10 +1,10 @@ #ifdef USE_PRAGMA_IDENT_HDR -#pragma ident "@(#)os.hpp 1.223 07/10/04 10:49:22 JVM" +#pragma ident "@(#)os.hpp 1.224 09/02/13 08:59:31 JVM" #endif /* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -116,10 +116,11 @@ static jlong elapsed_frequency(); // Return current local time in a string (YYYY-MM-DD HH:MM:SS). // It is MT safe, but not async-safe, as reading time zone // information may require a lock on some platforms. + static struct tm* localtime_pd (const time_t* clock, struct tm* res); static char* local_time_string(char *buf, size_t buflen); // Fill in buffer with current local time as an ISO-8601 string. // E.g., YYYY-MM-DDThh:mm:ss.mmm+zzzz. // Returns buffer, or NULL if it failed. static char* iso8601_time(char* buffer, size_t buffer_length);
13-02-2009

EVALUATION Se main cr
09-02-2009