JDK-4039157 : deadlock when two threads invoke InetAddress.getHostName()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.1,1.1.1,1.1.4
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS:
    solaris_2.5.1,solaris_2.6,windows_95 solaris_2.5.1,solaris_2.6,windows_95
  • CPU: x86,sparc
  • Submitted: 1997-03-14
  • Updated: 2000-03-27
  • Resolved: 2000-03-27
Related Reports
Duplicate :  
Description

Name: sgC58550			Date: 03/14/97


I have run into this bug on several occasions, and it seems to be deep in the im
plementation of InetAddress.getHostName(). Here is the thread dump and associate
d code.
 
SunOS wham 5.5.1 Generic_103640-05 sun4u sparc SUNW,Ultra-2
 
java version "1.1_Final"
 
    "Thread-7" (TID:0xeb004ea0, sys_thread_t:0xeaf01de0, state:MW) prio=5
        java.net.InetAddress.getHostName(InetAddress.java)
        java.net.InetAddress.toString(InetAddress.java)
        eweb.chat.server.ConsoleAgentServer.run(ConsoleAgentServer.java:73)
        java.lang.Thread.run(Thread.java)
    "MsgServer" (TID:0xeb004e08, sys_thread_t:0xeaf31de0, state:MW) prio=5
        java.net.InetAddress.getHostName(InetAddress.java)
        java.net.InetAddress.toString(InetAddress.java)
        eweb.msg.ServerMsgConnection.<init>(ServerMsgConnection.java:86)
        eweb.msg.MsgServer.run(MsgServer.java:84)
 
         unknown key (key=0xeaea1698):     monitor owner eaf01de0: "Thread-7"
        Waiting to enter:
            "MsgServer"
         unknown key (key=0xef5f42c0):     monitor owner eaf31de0: "MsgServer"
        Waiting to enter:
            "Thread-7"
 
------------------------------------------------------------------
 
deadlock occurs when a connection is made to this port, and
  InetAddress.getHostName is invoked. I haven't been able to pin down where
  this lock occurs, as the monitor key is unknown, and I suspect that the
  problem may be in libnet.so via the InetAddressImpl calls
 
Thread-7: eweb.chat.server.ConsoleAgentServer.run(ConsoleAgentServer.java:73)
          Socket s = ss.accept();
          InputStream in = s.getInputStream();
          OutputStream out = s.getOutputStream();
          InetAddress addr = s.getInetAddress();              |||||||||||||||
          if (checkAddress( addr )) {                         VVVVVVVVVVVVVVV
-->         ConsoleAgent ca = new ConsoleAgent( this, server, addr.toString(),
                                              in, out );
 
------------------------------------------------------------------
 
creation of a different type of connection established on a different
  port than above.
 
MsgServer: eweb.msg.ServerMsgConnection.<init>(ServerMsgConnection.java:86)
 
  public ServerMsgConnection( Socket socket, ... ) {
    this.socket = socket;
...
      inetAddr = socket.getInetAddress();
-->   iaString = inetAddr.toString();
 


company - EarthWeb , email - ###@###.###
======================================================================

Sue Palmer (3/18/97)  More info from customer:

The problem has been seen only on Solaris.  

The customer (EarthWeb) was able to  work around the deadlock in this particular case because one of the calls to getHostName() was being made for debugging output.  


elizabeth.mezias@Eng 1998-08-18
import java.net.*;

public class hostBugDemo {

    public InetAddress host;

    public hostBugDemo() {
	try {	host = InetAddress.getLocalHost(); 
		System.out.println("Address:" + host); }
	catch(Exception e) 
	  { System.err.println("Addressing error:" + e); }
	hostThread t1 = new hostThread();
	hostThread t2 = new hostThread();
	hostThread t3 = new hostThread();
	hostThread t4 = new hostThread();
	t1.run();
	t2.run();
	t3.run();
	t4.run();
    }


class hostThread extends Thread {
	public hostThread() { super(); }

	public void run() {
	String hn = host.getHostName();
	System.out.println("Host: " + hn);
	while(true) {
	  try {
	    Thread.sleep(2000);
	    }
	  catch(InterruptedException exp) {}
	  }
	}
  }

public static void main(String args[]) {

	hostBugDemo test = new hostBugDemo();


  }

}


Comments
EVALUATION This is probably the same deadlock that the JWS folks are seeing with green. benjamin.renaud@Eng 1997-11-12 I couldn't reproduce the problem. There is one test program contained in the description field. but it looks bogus to me. I would really like the customer to provide a test case. yingxian.wang@eng 2000-03-24 Sent email to customer requesting a more complete test case sheri.good@Eng 2000-03-27 Reply from ###@###.### This bug is no longer an issue with my customer. The description looked similar to what my customer was seeing, but they moved on to JDK1.2.2 with a new version of their application and the problem no longer exists. sheri.good@Eng 2000-03-27 I couldn't get more information from the customer. In the meantime, this bug could very well be solved by the fix for 4258193 java.net.InetAddress#getByName() deadlocks, which is putback in JDK1.3 RC1. yingxian.wang@eng 2000-03-27
27-03-2000

WORK AROUND elizabeth.mezias@Eng 1998-06-15 my customer is using synchronization in order to work around this deadlock
15-06-1998