-
Bug
-
Resolution: Unresolved
-
P4
-
23
This test can fail because multiple threads can hold re-entrant locks, not just the threads started by the test.
For example, here is some output from `jstack -l`:
"Common-Cleaner" #18 daemon prio=8 tid=0x00007f7c48210420 nid=339258 waiting on condition [0x00007f7c21f2e000]
java.lang.Thread.State: RUNNABLE
JavaThread state: _thread_blocked
- java.util.concurrent.locks.AbstractQueuedSynchronizer.release(int) @bci=0, line=1059 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.enableWait(java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode) @bci=62, line=1575 (Interpreted frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(long, java.util.concurrent.TimeUnit) @bci=37, line=1842 (Compiled frame)
- java.lang.ref.ReferenceQueue.await(long) @bci=8, line=71 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove0(long) @bci=18, line=143 (Compiled frame)
- java.lang.ref.ReferenceQueue.remove(long) @bci=36, line=218 (Compiled frame)
- jdk.internal.ref.CleanerImpl.run() @bci=45, line=140 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
- jdk.internal.misc.InnocuousThread.run() @bci=20, line=186 (Compiled frame)
Locked ownable synchronizers:
- <0x00000000ffd7c828>, (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
"Thread-0" #20 prio=5 tid=0x00007f7c4826aff0 nid=339281 waiting on condition [0x00007f7c21d2c000]
java.lang.Thread.State: WAITING (parking)
JavaThread state: _thread_blocked
- jdk.internal.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
- parking to wait for <0x00000000ffc2f5f0> (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
- java.util.concurrent.locks.LockSupport.park(java.lang.Object) @bci=27, line=221 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.util.concurrent.locks.AbstractQueuedSynchronizer$Node, int, boolean, boolean, boolean, long) @bci=361, line=754 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(int) @bci=15, line=990 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock$Sync.lock() @bci=9, line=153 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock.lock() @bci=4, line=322 (Compiled frame)
- LingeredAppWithConcurrentLock.lockMethod(java.util.concurrent.locks.Lock) @bci=1, line=35 (Compiled frame)
- LingeredAppWithConcurrentLock.lambda$main$0() @bci=3, line=46 (Compiled frame)
- LingeredAppWithConcurrentLock$$Lambda+0x00007f7bd3001878.run() @bci=0 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
Locked ownable synchronizers:
- None
"Thread-1" #21 prio=5 tid=0x00007f7c4826bd70 nid=339282 waiting on condition [0x00007f7c21c2b000]
java.lang.Thread.State: WAITING (parking)
JavaThread state: _thread_blocked
- jdk.internal.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
- parking to wait for <0x00000000ffc2f5f0> (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
- java.util.concurrent.locks.LockSupport.park(java.lang.Object) @bci=27, line=221 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.util.concurrent.locks.AbstractQueuedSynchronizer$Node, int, boolean, boolean, boolean, long) @bci=361, line=754 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(int) @bci=15, line=990 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock$Sync.lock() @bci=9, line=153 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock.lock() @bci=4, line=322 (Compiled frame)
- LingeredAppWithConcurrentLock.lockMethod(java.util.concurrent.locks.Lock) @bci=1, line=35 (Interpreted frame)
- LingeredAppWithConcurrentLock.lambda$main$1() @bci=3, line=47 (Compiled frame)
- LingeredAppWithConcurrentLock$$Lambda+0x00007f7bd3001aa0.run() @bci=0 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
Locked ownable synchronizers:
- None
"Thread-2" #22 prio=5 tid=0x00007f7c482724f0 nid=339283 waiting on condition [0x00007f7c21b2a000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
JavaThread state: _thread_blocked
- java.lang.Thread.sleepNanos0(long) @bci=0 (Compiled frame; information may be imprecise)
- java.lang.Thread.sleepNanos(long) @bci=33, line=496 (Compiled frame)
- java.lang.Thread.sleep(long) @bci=25, line=527 (Compiled frame)
- LingeredAppWithConcurrentLock.lockMethod(java.util.concurrent.locks.Lock) @bci=13, line=38 (Compiled frame)
- locked <0x00000000ffc2f5e0> (a java.util.concurrent.locks.ReentrantLock)
- LingeredAppWithConcurrentLock.lambda$main$2() @bci=3, line=48 (Compiled frame)
- LingeredAppWithConcurrentLock$$Lambda+0x00007f7bd3001cc8.run() @bci=0 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
Locked ownable synchronizers:
- <0x00000000ffc2f5f0>, (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
The test finds the 0x00000000ffd7c828 lock held by "Common-Cleaner" and expects to find another thread parking to wait for it.
For example, here is some output from `jstack -l`:
"Common-Cleaner" #18 daemon prio=8 tid=0x00007f7c48210420 nid=339258 waiting on condition [0x00007f7c21f2e000]
java.lang.Thread.State: RUNNABLE
JavaThread state: _thread_blocked
- java.util.concurrent.locks.AbstractQueuedSynchronizer.release(int) @bci=0, line=1059 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.enableWait(java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode) @bci=62, line=1575 (Interpreted frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(long, java.util.concurrent.TimeUnit) @bci=37, line=1842 (Compiled frame)
- java.lang.ref.ReferenceQueue.await(long) @bci=8, line=71 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove0(long) @bci=18, line=143 (Compiled frame)
- java.lang.ref.ReferenceQueue.remove(long) @bci=36, line=218 (Compiled frame)
- jdk.internal.ref.CleanerImpl.run() @bci=45, line=140 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
- jdk.internal.misc.InnocuousThread.run() @bci=20, line=186 (Compiled frame)
Locked ownable synchronizers:
- <0x00000000ffd7c828>, (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
"Thread-0" #20 prio=5 tid=0x00007f7c4826aff0 nid=339281 waiting on condition [0x00007f7c21d2c000]
java.lang.Thread.State: WAITING (parking)
JavaThread state: _thread_blocked
- jdk.internal.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
- parking to wait for <0x00000000ffc2f5f0> (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
- java.util.concurrent.locks.LockSupport.park(java.lang.Object) @bci=27, line=221 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.util.concurrent.locks.AbstractQueuedSynchronizer$Node, int, boolean, boolean, boolean, long) @bci=361, line=754 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(int) @bci=15, line=990 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock$Sync.lock() @bci=9, line=153 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock.lock() @bci=4, line=322 (Compiled frame)
- LingeredAppWithConcurrentLock.lockMethod(java.util.concurrent.locks.Lock) @bci=1, line=35 (Compiled frame)
- LingeredAppWithConcurrentLock.lambda$main$0() @bci=3, line=46 (Compiled frame)
- LingeredAppWithConcurrentLock$$Lambda+0x00007f7bd3001878.run() @bci=0 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
Locked ownable synchronizers:
- None
"Thread-1" #21 prio=5 tid=0x00007f7c4826bd70 nid=339282 waiting on condition [0x00007f7c21c2b000]
java.lang.Thread.State: WAITING (parking)
JavaThread state: _thread_blocked
- jdk.internal.misc.Unsafe.park(boolean, long) @bci=0 (Compiled frame; information may be imprecise)
- parking to wait for <0x00000000ffc2f5f0> (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
- java.util.concurrent.locks.LockSupport.park(java.lang.Object) @bci=27, line=221 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.util.concurrent.locks.AbstractQueuedSynchronizer$Node, int, boolean, boolean, boolean, long) @bci=361, line=754 (Compiled frame)
- java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(int) @bci=15, line=990 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock$Sync.lock() @bci=9, line=153 (Compiled frame)
- java.util.concurrent.locks.ReentrantLock.lock() @bci=4, line=322 (Compiled frame)
- LingeredAppWithConcurrentLock.lockMethod(java.util.concurrent.locks.Lock) @bci=1, line=35 (Interpreted frame)
- LingeredAppWithConcurrentLock.lambda$main$1() @bci=3, line=47 (Compiled frame)
- LingeredAppWithConcurrentLock$$Lambda+0x00007f7bd3001aa0.run() @bci=0 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
Locked ownable synchronizers:
- None
"Thread-2" #22 prio=5 tid=0x00007f7c482724f0 nid=339283 waiting on condition [0x00007f7c21b2a000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
JavaThread state: _thread_blocked
- java.lang.Thread.sleepNanos0(long) @bci=0 (Compiled frame; information may be imprecise)
- java.lang.Thread.sleepNanos(long) @bci=33, line=496 (Compiled frame)
- java.lang.Thread.sleep(long) @bci=25, line=527 (Compiled frame)
- LingeredAppWithConcurrentLock.lockMethod(java.util.concurrent.locks.Lock) @bci=13, line=38 (Compiled frame)
- locked <0x00000000ffc2f5e0> (a java.util.concurrent.locks.ReentrantLock)
- LingeredAppWithConcurrentLock.lambda$main$2() @bci=3, line=48 (Compiled frame)
- LingeredAppWithConcurrentLock$$Lambda+0x00007f7bd3001cc8.run() @bci=0 (Compiled frame)
- java.lang.Thread.runWith(java.lang.Object, java.lang.Runnable) @bci=5, line=1588 (Compiled frame)
- java.lang.Thread.run() @bci=19, line=1575 (Compiled frame)
Locked ownable synchronizers:
- <0x00000000ffc2f5f0>, (a java/util/concurrent/locks/ReentrantLock$NonfairSync)
The test finds the 0x00000000ffd7c828 lock held by "Common-Cleaner" and expects to find another thread parking to wait for it.