-
Bug
-
Resolution: Fixed
-
P3
-
8u40
-
b137
-
x86_64
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8197341 | 8u192 | Vyom Tewari | P3 | Resolved | Fixed | b01 |
JDK-8189503 | 8u172 | Vyom Tewari | P3 | Resolved | Fixed | b03 |
JDK-8189556 | 8u162 | Vyom Tewari | P3 | Resolved | Fixed | b02 |
JDK-8183485 | 8u161 | Vyom Tewari | P3 | Resolved | Fixed | b01 |
JDK-8172578 | 8u152 | Vyom Tewari | P3 | Resolved | Fixed | b01 |
JDK-8184443 | 8u151 | Vyom Tewari | P3 | Resolved | Fixed | b05 |
JDK-8185234 | 8u144 | Vyom Tewari | P3 | Resolved | Fixed | b31 |
JDK-8183082 | 8u141 | Vyom Tewari | P3 | Resolved | Fixed | b31 |
JDK-8182665 | 8u131 | Vyom Tewari | P3 | Resolved | Fixed | b34 |
JDK-8192432 | emb-8u161 | Vyom Tewari | P3 | Resolved | Fixed | b01 |
JDK-8185284 | emb-8u151 | Vyom Tewari | P3 | Resolved | Fixed | b05 |
JDK-8180513 | 7u171 | Robert Mckenna | P3 | Resolved | Fixed | b01 |
JDK-8184442 | 7u161 | Robert Mckenna | P3 | Resolved | Fixed | b05 |
JDK-8182435 | 7u151 | Robert Mckenna | P3 | Resolved | Fixed | b31 |
JDK-8181697 | 7u141 | Robert Mckenna | P3 | Closed | Fixed | b33 |
JDK-8183241 | 7u131 | Robert Mckenna | P3 | Resolved | Fixed | b32 |
JDK-8193986 | openjdk7u | Vyom Tewari | P3 | Resolved | Fixed | master |
A DESCRIPTION OF THE PROBLEM :
As noted at
In production, we hit this about once a day. For testing and reproduction purposes, we can use fault injection to get spurious poll() results on demand.
[This report is probably more appropriate as a comment on
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create file called poll.c with contents:
-----
#define _GNU_SOURCE
#include <poll.h>
#include <dlfcn.h>
#include <stdio.h>
int poll(struct pollfd *fds, nfds_t nfds, int timeout) {
static int n;
if ((++n & 0x3) == 0) {
// Fault injection: perhaps we should report a spurious readiness notification
int i;
for (i = 0; i < nfds; ++i) {
if (fds[i].events & POLLIN) {
fds[i].revents |= POLLIN;
return 1;
}
}
}
return ((int(*)(struct pollfd*,nfds_t,int))dlsym(RTLD_NEXT, "poll"))(fds, nfds, timeout);
}
-----
2. Create file called OneReaderThread.java with contents:
-----
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class OneReaderThread {
public static void main(String[] args) throws IOException {
@SuppressWarnings("resource")
ServerSocket serverSocket = new ServerSocket(17291);
new ReadingThreadA().start();
Socket client = serverSocket.accept();
OutputStream os = client.getOutputStream();
byte[] writeData = new byte[2];
for (;;) {
waitingForA = true;
long start = System.currentTimeMillis();
while (waitingForA) {
long now = System.currentTimeMillis();
if (now > start + 500) {
// 500ms have passed, which is 10x the read timeout
System.out.println("Should never happen: A is unresponsive");
os.write(writeData);
break;
}
}
}
}
private static volatile boolean waitingForA;
private static final class ReadingThreadA extends Thread {
@Override
public void run() {
try {
@SuppressWarnings("resource")
Socket s = new Socket("localhost", 17291);
s.setSoTimeout(50); // SO_TIMEOUT is set, meaning that reads should not block for more than 50ms
final InputStream is = s.getInputStream();
byte[] readDataA = new byte[2];
for (;;) {
int n = 0;
try {
n = is.read(readDataA);
} catch (IOException e) {
// Ignore
}
System.out.println("A tick (" + n + ")");
waitingForA = false; // This assignment should happen at least once every 50ms
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
-----
3. Compile the C code: gcc -o poll.so -shared poll.c -ldl -fPIC
4. Compile the Java code: javac OneReaderThread.java
5. Run the Java code with the C library preloaded: LD_PRELOAD=./poll.so java -cp . OneReaderThread
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect an output stream consisting solely of:
A tick (0)
A tick (0)
A tick (0)
A tick (0)
A tick (0)
A tick (0)
A tick (0)
A tick (0)
ACTUAL -
Actual output stream is repetitions of:
Should never happen: A is unresponsive
A tick (2)
A tick (0)
A tick (0)
A tick (0)
Should never happen: A is unresponsive
A tick (2)
A tick (0)
A tick (0)
A tick (0)
REPRODUCIBILITY :
This bug can be reproduced occasionally.
- backported by
-
JDK-8172578 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8180513 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8182435 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8182665 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8183082 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8183241 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8183485 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8184442 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8184443 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8185234 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8185284 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8189503 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8189556 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8192432 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8193986 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8197341 SocketInputStream.socketRead0 can hang even with soTimeout set
- Resolved
-
JDK-8181697 SocketInputStream.socketRead0 can hang even with soTimeout set
- Closed
- duplicates
-
JDK-8049846 SocketInputStream.socketRead0 hangs even with soTimeout under high load
- Closed
-
JDK-8143305 sun/security/ec/TestEC.java fails intermittently
- Closed
-
JDK-8143992 SocketInputStream.socketRead0 hangs even with soTimeout under high load
- Closed
- relates to
-
JDK-8233660 Symptoms from JDK-8075484 still show up in Java 8u231
- Closed