--- old/src/hotspot/share/prims/jvmtiEnvBase.cpp 2020-02-03 17:42:06.000000000 -0500 +++ new/src/hotspot/share/prims/jvmtiEnvBase.cpp 2020-02-03 17:42:05.000000000 -0500 @@ -651,14 +651,22 @@ #ifdef ASSERT uint32_t debug_bits = 0; #endif + // Note: The is_thread_fully_suspended() part of the assert() is + // from an older implementation that recognized suspension as + // being safe. However, that was racy in the face of rogue resumes. + // Should be replaced with "calling_thread == java_thread". assert((SafepointSynchronize::is_at_safepoint() || java_thread->is_thread_fully_suspended(false, &debug_bits)), "at safepoint or target thread is suspended"); oop obj = NULL; - ObjectMonitor *mon = java_thread->current_waiting_monitor(); + // For all of the get_current_contended_monitor() call sites, we + // are either at a safepoint or the calling thread is operating + // on itself so this ObjectMonitorHandle is not strictly necessary. + ObjectMonitorHandle omh; + ObjectMonitor *mon = java_thread->current_waiting_monitor(&omh); if (mon == NULL) { // thread is not doing an Object.wait() call - mon = java_thread->current_pending_monitor(); + mon = java_thread->current_pending_monitor(&omh); if (mon != NULL) { // The thread is trying to enter() an ObjectMonitor. obj = (oop)mon->object(); @@ -734,16 +742,24 @@ HandleMark hm; oop wait_obj = NULL; { + // For all of the get_locked_objects_in_frame() call sites, we + // are either at a safepoint or the calling thread is operating + // on itself so this ObjectMonitorHandle is not strictly necessary. + ObjectMonitorHandle omh; // save object of current wait() call (if any) for later comparison - ObjectMonitor *mon = java_thread->current_waiting_monitor(); + ObjectMonitor *mon = java_thread->current_waiting_monitor(&omh); if (mon != NULL) { wait_obj = (oop)mon->object(); } } oop pending_obj = NULL; { + // For all of the get_locked_objects_in_frame() call sites, we + // are either at a safepoint or the calling thread is operating + // on itself so this ObjectMonitorHandle is not strictly necessary. + ObjectMonitorHandle omh; // save object of current enter() call (if any) for later comparison - ObjectMonitor *mon = java_thread->current_pending_monitor(); + ObjectMonitor *mon = java_thread->current_pending_monitor(&omh); if (mon != NULL) { pending_obj = (oop)mon->object(); }