Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6276939

InetAddress deadlock under low-memory conditions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • None
    • generic
    • generic

      From InetAddress.java:

                  } finally {
                      // Cache the address.
                      cacheAddress(host, obj, success);
                      // Delete the host from the lookupTable, and
                      // notify all threads waiting for the monitor
                      // for lookupTable.
                      updateLookupTable(host);
                  }

      If cacheAddress() throws an exception, such as OutOfMemoryError,
      then updateLookupTable() will not get called. This will
      cause future lookups of this host to wait forever in
      checkLookupTable().

      ###@###.### 2005-05-27 00:30:53 GMT

      A test case follows:

      ----
      import java.net.InetAddress;
      import java.net.UnknownHostException;

      public class test2 {
          public static void main(String args[]) {
              System.setProperty("sun.simulate.outofmemory", "true");
              try {
                  InetAddress.getByName("localhost");
              } catch (Exception e) {
              }
              System.setProperty("sun.simulate.outofmemory", "false");
              try {
                  InetAddress.getByName("localhost");
              } catch (Exception e) {
              }
          }
      }
      ----

      Because the out-of-memory error needs to happen in a very specific
      place, the easiest way to reproduce the problem is either to
      modify cacheAddress() in InetAddress.java to do something like:

      if (System.getProperty("sun.simulate.outofmemory").equals("true")) {
          throw new RuntimeException("Out of memory");
      }

      or run inside a debugger and force an out-of-memory error at
      the correct time.

      ###@###.### 2005-06-16 07:01:27 GMT

            chegar Chris Hegarty
            dlong Dean Long
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: