Name: stC104175 Date: 05/10/2000
java version "1.1.8"
We've been having JVM crashes on NT 4.0 SP 5 at random intervals when using a
multithreaded program that uses sockets. I've developed a test program, below,
that demonstrates the problem if you run it on an NT machine with 2 or more
processors with JDK 1.1.8; about 1 time out of every 10 it will cause the JVM to
abort with a Dr Watson error "Exception number: c0000005 (access violation)".
The crashing thread is always running in javai.dll method jio_snprintf; the
memory address is usually 1003ed4f or 74706563. Within jio_snprintf, it seems
to be calling Winsock functions in msafd.dll.
The test program does not crash when running on a single-processor NT machine,
nor have I seen it crash when using JDK 1.2.2 on a dual-processor machine.
This bug may be related to other multiprocessor NT bugs in this database, such
as 4236062 and 4318843, although those bugs focus on problems in AWT and Swing
classes, not sockets.
Microsoft's Knowledge Base article Q142654 mentions a similar-sounding bug in
Proxy Server, although that bug was fixed (or worked around) in SP3 and we are
using SP 5.
The test program requires one parameter: the name of a host machine that is
running HTTP (web) service on port 80. The web server must have a file
"/index.html"; the test program does an HTTP GET to get that file. For example:
java NTSockets www.vue.com
Here is the code:
import java.net.Socket;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
public class NTSockets extends Thread {
public static void main(String args[]) {
try {
if (args.length >= 1) {
String machine = args[0];
int nthreads = 2;
// Make the threads.
NTSockets[] inst = new NTSockets[nthreads];
for (int i = 0; i < nthreads; i++)
inst[i] = new NTSockets(machine, i);
// Start the threads.
System.out.println("Starting " + nthreads + "
thread(s)");
for (int i = 0; i < nthreads; i++)
inst[i].start(); // calls
run() to start the instance
// Wait for all threads to be finished.
while (true) {
Thread.sleep(200);
int alive = 0;
for (int i = 0; i < nthreads; i++) {
if (inst[i].isAlive())
alive++;
}
System.out.println("Alive " + alive);
if (alive == 0)
break;
}
}
else {
System.out.println("Usage: java NTSockets
hostMachine");
System.out.println("Example: java NTSockets
www.vue.com");
}
}
catch (Exception ex) {
ex.printStackTrace();
}
System.exit(0);
}
/// Instance variables:
private String host; // host to connect to on port 80
private int threadNum; // thread number
/// Constructors:
public NTSockets(String host, int threadNum) {
this.host = host;
this.threadNum = threadNum;
}
/// Public methods:
public void run() {
WebPage newPage;
WebPage page;
try {
for (int i = 0; i < 2; i++) {
Socket socket = null;
OutputStream out = null;
InputStream in = null;
System.out.println(threadNum + ": Connect " +
i);
socket = new Socket(host, 80);
out = socket.getOutputStream();
in = socket.getInputStream();
// Send an HTTP GET request.
System.out.println(threadNum + ": Send " + i);
String msg = "GET /index.html HTTP/1.1\nHost: "
+ host + "\n\n";
sendHTTPMessage(out, msg);
// Get the reply.
System.out.println(threadNum + ": Recv " + i);
String inData = receiveHTTPMessage(in);
socket.close();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
return;
}
/// Private methods:
private String receiveHTTPMessage(InputStream in) throws IOException {
String msg = null;
int posn = 0;
int len = 0;
byte[] inData = new byte[1000];
while ((len = in.read(inData, posn, inData.length - posn)) >= 0)
{
posn += len;
if (posn >= inData.length)
break;
}
msg = new String(inData, 0, inData.length);
return msg;
}
private void sendHTTPMessage(OutputStream out, String msg) throws
IOException {
byte[] outData = msg.getBytes();
out.write(outData);
out.flush();
}
}
(Review ID: 104683)
======================================================================
- duplicates
-
JDK-4151449 (1.1) Trap in interpreter due to bytecode rewriting
-
- Closed
-