diff src/share/vm/runtime/objectMonitor.cpp @ 17965:4a1062dc52d1

8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock' Summary: Add a !owner check for 'waiting to lock' to catch current_pending_monitor corner cases. Reviewed-by: dholmes, sspitsyn, kmo, zgu Contributed-by: rednaxelafx@gmail.com, zhengyu.gu@oracle.com, daniel.daugherty@oracle.com
author dcubed
date Wed, 04 Jun 2014 06:25:53 -0700
parents a7d4d4655766
children 52b4284cb496 ce8f6bb717c9
line wrap: on
line diff
--- a/src/share/vm/runtime/objectMonitor.cpp	Fri May 30 10:43:51 2014 +0200
+++ b/src/share/vm/runtime/objectMonitor.cpp	Wed Jun 04 06:25:53 2014 -0700
@@ -418,6 +418,15 @@
       jt->java_suspend_self();
     }
     Self->set_current_pending_monitor(NULL);
+
+    // We cleared the pending monitor info since we've just gotten past
+    // the enter-check-for-suspend dance and we now own the monitor free
+    // and clear, i.e., it is no longer pending. The ThreadBlockInVM
+    // destructor can go to a safepoint at the end of this block. If we
+    // do a thread dump during that safepoint, then this thread will show
+    // as having "-locked" the monitor, but the OS and java.lang.Thread
+    // states will still report that the thread is blocked trying to
+    // acquire it.
   }
 
   Atomic::dec_ptr(&_count);