Details
-
Bug
-
Resolution: Fixed
-
P2
-
6u11, 6u17
-
b55
-
x86, sparc
-
solaris_10, windows_xp
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2192006 | 6u21 | Vladislav Karnaukhov | P2 | Closed | Fixed | b03 |
JDK-2191895 | 6u20-rev | Vladislav Karnaukhov | P2 | Closed | Fixed | b03 |
JDK-2188980 | 6u19-rev | Vladislav Karnaukhov | P2 | Closed | Fixed | b06 |
JDK-2188917 | 6u13-crev | Vladislav Karnaukhov | P2 | Resolved | Fixed | b03 |
JDK-2187547 | 6u13 | Vladislav Karnaukhov | P2 | Closed | Won't Fix | |
JDK-2186941 | 6u6-crev | Vladislav Karnaukhov | P2 | Resolved | Fixed | b02 |
JDK-2187504 | 6u6 | Vladislav Karnaukhov | P2 | Closed | Won't Fix | |
JDK-2175059 | OpenJDK6 | Martin Buchholz | P3 | Resolved | Fixed | b16 |
Description
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP3
EXTRA RELEVANT SYSTEM CONFIGURATION :
P4 2.8HT
A DESCRIPTION OF THE PROBLEM :
Semaphore initial state 0. 4 threads run 4 tasks.
Two threads run acquire semaphore once, the other two threads run release semaphore once.
One possible result is the semaphore state value is 1 and one thread still waiting.
The possible reason:
When AbstractQueuedSynchronizer#release are called, head.waitStatus may be 0 because the previous acquire thread may run at AbstractQueuedSynchronizer#doAcquireShared before setHeadAndPropagate is called.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The given executable test case will hung. Suggest using dual-core CPU or HT CPU to reproduce.
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import java.util.concurrent.Semaphore;
public class TestSemaphore {
private static Semaphore sem = new Semaphore(0);
private static class Thread1 extends Thread {
@Override
public void run() {
sem.acquireUninterruptibly();
}
}
private static class Thread2 extends Thread {
@Override
public void run() {
sem.release();
}
}
public static void main(String[] args) throws InterruptedException {
for (int i = 0; i < 10000000; i++) {
Thread t1 = new Thread1();
Thread t2 = new Thread1();
Thread t3 = new Thread2();
Thread t4 = new Thread2();
t1.start();
t2.start();
t3.start();
t4.start();
t1.join();
t2.join();
t3.join();
t4.join();
System.out.println(i);
}
}
}
---------- END SOURCE ----------
Attachments
Issue Links
- backported by
-
JDK-2186941 Concurrent Semaphore release may cause some require thread not signaled
- Resolved
-
JDK-2188917 Concurrent Semaphore release may cause some require thread not signaled
- Resolved
-
JDK-2175059 Concurrent Semaphore release may cause some require thread not signaled
- Resolved
-
JDK-2187504 Concurrent Semaphore release may cause some require thread not signaled
- Closed
-
JDK-2187547 Concurrent Semaphore release may cause some require thread not signaled
- Closed
-
JDK-2188980 Concurrent Semaphore release may cause some require thread not signaled
- Closed
-
JDK-2191895 Concurrent Semaphore release may cause some require thread not signaled
- Closed
-
JDK-2192006 Concurrent Semaphore release may cause some require thread not signaled
- Closed
- relates to
-
JDK-6822370 ReentrantReadWriteLock: threads hung when there are no threads holding onto the lock (Netra x4450)
- Closed
-
JDK-6241823 Infinite loop in timed Semaphore.tryAcquire
- Closed
-
JDK-6956836 java/util/concurrent/Semaphore/RacingReleases.java fails
- Closed
-
JDK-7011859 java/util/concurrent/Semaphore/RacingReleases.java failing
- Closed
-
JDK-6803402 Race condition in AbstractQueuedSynchronizer
- Resolved