JDK-4291325 : JVM Hangs in java.net.InetAddress.checkLookupTable() on a 2-way E3000
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1999-11-14
  • Updated: 2001-02-05
  • Resolved: 2001-02-05
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 11/14/99


java version "1.2.2"
HotSpot VM (1.0.1, mixed mode, build f)

I have a simple test program (see below) that spawns 10 threads that all
retrieve the same web page using URLConnection. Ocassionally the JVM hangs. I
created this test case as a result of a production problem we are having.

The box this runs on is a Sun E3000 with 2 CPUs.

Once hung the following is the full thread dump:

"Thread-10" prio=5 tid=0x2b6d8 nid=0x1 runnable [0..0xeffff720]

"Thread-9" prio=5 tid=0x1251f8 nid=0x13 waiting on monitor
[0xe4c0f000..0xe4c0fa60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-8" prio=5 tid=0x124890 nid=0x12 waiting on monitor
[0xe5101000..0xe5101a60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-7" prio=5 tid=0x124328 nid=0x11 runnable [0xe5203000..0xe5203a60]
	at sun.net.InetAddressCachePolicy.get(InetAddressCachePolicy.java:56)
	at java.net.InetAddress.getCachedAddress(InetAddress.java:329)
	at java.net.InetAddress.getAllByName0(InetAddress.java:569)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-6" prio=5 tid=0x1239c0 nid=0x10 waiting on monitor
[0xe5305000..0xe5305a60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-5" prio=5 tid=0x123058 nid=0xf waiting on monitor
[0xe5407000..0xe5407a60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-4" prio=5 tid=0x120ed8 nid=0xe waiting on monitor
[0xe5509000..0xe5509a60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-3" prio=5 tid=0x11eb78 nid=0xd waiting on monitor
[0xe560b000..0xe560ba60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-2" prio=5 tid=0x11e210 nid=0xc waiting on monitor
[0xe570d000..0xe570da60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-1" prio=5 tid=0x11e0a8 nid=0xb runnable [0xe580f000..0xe580fa60]
	at java.net.InetAddress.cacheAddress(InetAddress.java:315)
	at java.net.InetAddress.cacheAddress(InetAddress.java:308)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:638)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Thread-0" prio=5 tid=0x11df40 nid=0xa waiting on monitor
[0xee501000..0xee501a60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.net.InetAddress.checkLookupTable(InetAddress.java:668)
	at java.net.InetAddress.getAddressFromNameService(InetAddress.java:614)
	at java.net.InetAddress.getAllByName0(InetAddress.java:574)
	at java.net.InetAddress.getAllByName0(InetAddress.java:546)
	at java.net.InetAddress.getByName(InetAddress.java:455)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:250)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:270)
	at sun.net.www.http.HttpClient.New(HttpClient.java:282)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:372)
	at Runner.getPage(Runner.java:41)
	at Runner.run(Runner.java:81)
	at java.lang.Thread.run(Thread.java:479)

"Signal Dispatcher" daemon prio=10 tid=0x10fee8 nid=0x9 runnable [0..0]

"Finalizer" daemon prio=8 tid=0x8ac80 nid=0x7 waiting on monitor
[0xee807000..0xee807a60]
	at java.lang.Object.wait(Native Method)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:112)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:174)

"Reference Handler" daemon prio=10 tid=0x914b0 nid=0x6 waiting on monitor
[0xee909000..0xee909a60]
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:424)
	at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:114)

"VM Thread" prio=5 tid=0x8a3e8 nid=0x4 runnable

"VM Periodic Task Thread" prio=10 tid=0x10fe50 nid=0x8 waiting on monitor

A extract of the source is:

-------- Test.java

import java.util.*;

public class Test {
            
    public static void main(String[] argv) {
        for (int i = 0; i < 10; i++)
            new Thread(new Runner()).start();
    } // main

} // Test

---- Runner.java

import java.net.*;
import java.io.*;
import java.util.*;

public class Runner implements Runnable {

    private String getPage(String page) {
        InputStreamReader input= null;
        StringWriter output = new StringWriter();
        try {
            URL url = new URL(page);
            URLConnection u = url.openConnection();
            u.connect();
            input = new InputStreamReader(u.getInputStream());
            char[] streamBuffer = new char[256];
            while(true) {
                int bytesRead = input.read(streamBuffer);
                if (bytesRead == -1) break;
                output.write(streamBuffer, 0, bytesRead);
            } // while
        } catch (IOException e) {
            System.out.println("error opening page");
        } finally {
            if (input != null)
                try {
                    input.close();
                } catch (IOException e) {
                } // try
        } // try
        return output.toString();
    } // getPage

    public void run() {
	getPage("http://paces:9000/session/Login.po");
    } // run

} // Runner
(Review ID: 97820) 
======================================================================

Comments
EVALUATION This hang in 1.2.2 was caused by a bug in the synchronization used by InetAddress. This was fixed in 1.3 with bug 4258193. Therefore I am closing this as a duplicate. alan.bateman@ireland 2001-02-05
05-02-2001