One additional object sometimes appears on the lock stack while running test "vmTestbase/nsk/jdi/StepEvent/_itself_/stepEvent004/stepEvent004.java":
LockStack[1]: nsk.share.jdi.EventHandler
{0x00000000bcc102b8} - klass: 'nsk/share/jdi/EventHandler'
- ---- fields (total size 5 words):
- private volatile 'wasInterrupted' 'Z' @12 false (0x00)
- private 'debuggee' 'Lnsk/share/jdi/Debugee;' @16 a 'nsk/share/jdi/LocalLaunchedDebugee'{0x00000000bcb697f8} (0xbcb697f8)
- private 'log' 'Lnsk/share/Log;' @20 a 'nsk/share/Log'{0x00000000bcc7e538} (0xbcc7e538)
- private 'vm' 'Lcom/sun/jdi/VirtualMachine;' @24 a 'com/sun/tools/jdi/VirtualMachineImpl'{0x00000000bccc2d78} (0xbccc2d78)
- private 'requestManager' 'Lcom/sun/jdi/request/EventRequestManager;' @28 a 'com/sun/tools/jdi/EventRequestManagerImpl'{0x00000000bccc43c8} (0xbccc43c8)
- private 'listenThread' 'Ljava/lang/Thread;' @32 a 'java/lang/Thread'{0x00000000bcc101a0} (0xbcc101a0)
LockStack[0]: java.util.Collections$SynchronizedRandomAccessList
{0x00000000bca24b60} - klass: 'java/util/Collections$SynchronizedRandomAccessList'
- ---- fields (total size 3 words):
- final 'c' 'Ljava/util/Collection;' @12 a 'java/util/Vector'{0x00000000bca24b78} (0xbca24b78)
- final 'mutex' 'Ljava/lang/Object;' @16 a 'java/util/Collections$SynchronizedRandomAccessList'{0x00000000bca24b60} (0xbca24b60)
- final 'list' 'Ljava/util/List;' @20 a 'java/util/Vector'{0x00000000bca24b78} (0xbca24b78)
The obj at LockStack[0] is the one which is expected by the unlocking code in the C2 method:
J 1490% c2 nsk.share.jdi.EventHandler.run()V (475 bytes) @ 0x00007fff7c67139c [0x00007fff7c670f80+0x000000000000041c]
j java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5 java.base@22-internal
j java.lang.Thread.run()V+19 java.base@22-internal
v ~StubRoutines::call_stub 0x00007fff7bdc084c
Observed on linuxppc64le so far (intermittently). Other platforms may be affected, but were not observed, yet. Seems like there are at least similar or related problems (linked to JDK-8315880).
The platform code for all platforms only supports removing the top of the lock stack. In contrast, ObjectSynchronizer::exit calls LockStack::remove which is able to remove any object.
The issue does no longer show up when using the slow path instead of stop("Top of lock-stack does not match the unlocked object").