United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6900441 PlatformEvent.park(millis) on Linux could still be affected by changes to the time-of-day clock
6900441 : PlatformEvent.park(millis) on Linux could still be affected by changes to the time-of-day clock

Details
Type:
Bug
Submit Date:
2009-11-11
Status:
Open
Updated Date:
2012-07-23
Project Name:
JDK
Resolved Date:
Component:
hotspot
OS:
linux_ubuntu,linux
Sub-Component:
runtime
CPU:
x86,ppc,generic
Priority:
P4
Resolution:
Unresolved
Affected Versions:
e5.0u21,6,6u29,7
Targeted Versions:
tbd_major

Related Reports
Duplicate:
Relates:

Sub Tasks

Description
This is a continuation of 6311057 which only partially "fixed" the problem because Linux itself is operating incorrectly in this area. I have it on good authority that "The futex wait implementation is historically wrong." and that "I think with newer kernel/glibc combinations it will be correct."

The real fix here is to change the pthread_cond so that it is associated with the monotonic clock (pthread_condattr_setclock(CLOCK_MONOTONIC) - and with pthread_cond_init being passed the attr object) and to calculate the asbolute time as "millis from now" on the monotonic clock. This will make the PlatformEvent::park(millis) code immune to changes in the time-of-day clock.

This change is relatively simple but it does affect all timed-waiting calls that ultimately use PlatformEvent. This should be okay as the majority of Java APIs that involve timed-waiting all specify relative times the same as Thread.sleep. I believe this will cover Thread.sleep and Object.wait.

Note that there is a similar problem with the java.util.concurrent.locks.LockSupport.park methods which are implemented using the platform specific Parker class, which again uses a pthread_mutex and pthread_cond under the covers. However as they support both absolute and relative wait times the fix is more involved as we need to use the monotonic clock for relative waits, but the TOD clock for absolute ones! That would require using two different pthread_cond objects.

                                    

Comments
EVALUATION

See description.
                                     
2009-11-11



Hardware and Software, Engineered to Work Together