8185529: JCK api/java_lang/Object/WaitTests failed with jdk10/hs nightly
authordholmes
Mon, 09 Oct 2017 01:23:13 -0400
changeset 47604 a5abbaac6165
parent 47600 5c8607bb3d2d
child 47605 54acb845133e
8185529: JCK api/java_lang/Object/WaitTests failed with jdk10/hs nightly Reviewed-by: dcubed, ccheung
src/hotspot/os/posix/os_posix.cpp
--- a/src/hotspot/os/posix/os_posix.cpp	Fri Oct 06 22:40:31 2017 -0400
+++ b/src/hotspot/os/posix/os_posix.cpp	Mon Oct 09 01:23:13 2017 -0400
@@ -1770,6 +1770,12 @@
 
   if (v == 0) { // Do this the hard way by blocking ...
     struct timespec abst;
+    // We have to watch for overflow when converting millis to nanos,
+    // but if millis is that large then we will end up limiting to
+    // MAX_SECS anyway, so just do that here.
+    if (millis / MILLIUNITS > MAX_SECS) {
+      millis = jlong(MAX_SECS) * MILLIUNITS;
+    }
     to_abstime(&abst, millis * (NANOUNITS / MILLIUNITS), false);
 
     int ret = OS_TIMEOUT;