-
Bug
-
Resolution: Fixed
-
P3
-
6, 7, 8, 11, 15, 16
The spec for GetCurrentContendedMonitor states:
"Get the object, if any, whose monitor the specified thread is waiting to enter or waiting to regain through java.lang.Object.wait. "
but the implementation does:
ObjectMonitor *mon = java_thread->current_waiting_monitor();
if (mon == NULL) {
// thread is not doing an Object.wait() call
mon = java_thread->current_pending_monitor();
if (mon != NULL) {
// The thread is trying to enter() an ObjectMonitor.
obj = mon->object();
assert(obj != NULL, "ObjectMonitor should have a valid object!");
}
// implied else: no contended ObjectMonitor
} else {
// thread is doing an Object.wait() call
obj = mon->object();
assert(obj != NULL, "Object.wait() should have an object");
}
which detects either contended monitor enter or a call to Object.wait (or the internal variant used by class initialization). It does not check if the thread is trying to reenter the monitor as part of Object.wait, but simply checks if the thread is somewhere within the Object.wait call. That is wrong.
This is a long standing bug as far as I can see.
"Get the object, if any, whose monitor the specified thread is waiting to enter or waiting to regain through java.lang.Object.wait. "
but the implementation does:
ObjectMonitor *mon = java_thread->current_waiting_monitor();
if (mon == NULL) {
// thread is not doing an Object.wait() call
mon = java_thread->current_pending_monitor();
if (mon != NULL) {
// The thread is trying to enter() an ObjectMonitor.
obj = mon->object();
assert(obj != NULL, "ObjectMonitor should have a valid object!");
}
// implied else: no contended ObjectMonitor
} else {
// thread is doing an Object.wait() call
obj = mon->object();
assert(obj != NULL, "Object.wait() should have an object");
}
which detects either contended monitor enter or a call to Object.wait (or the internal variant used by class initialization). It does not check if the thread is trying to reenter the monitor as part of Object.wait, but simply checks if the thread is somewhere within the Object.wait call. That is wrong.
This is a long standing bug as far as I can see.
- csr for
-
JDK-8326024 JVM TI GetCurrentContendedMonitor is implemented incorrectly
-
- Closed
-