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

Inet4AddressImpl.getHostByAddr() throws exception in WinXP native code

XMLWordPrintable

    • b14
    • x86
    • windows_xp



      Name: rmT116609 Date: 01/09/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Windows XP Professional

      A DESCRIPTION OF THE PROBLEM :
      A small program I wrote to query host names from IP addresses found in an Apache access.log file runs for a short while and then aborts with an access violation in native code.

      It appears that specific IP addresses trigger the crash. My program first failed on the IP address 12.36.72.226 My program simply constructs InetAddress objects with InetAddress.getByName( ip ) and then calls getHostName() on the resulting object. It dfoes this many times successully before failing, but fails withing a minute or two. The ip address that it fails on appears to be reasonable. In any case an access violation in native code would not be acceptable since the InetAddress4 object is constructed succesfully and is therefore a valid object to call the method on.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. construct InetAddress object with InetAddress.getByName( ip )
      2. call getHostName() on the resulting object.
      3. Repeat 1 & 2 until failure (usually within 5 minutes)

      Perhaps this means nothing but for me it seems to always
      fail when given these IP addresses...
      12.36.72.226
      12.150.244.162
      207.203.254.110

      That is, if I specifically test for those addresses and skip them the loop continues for many more iterations.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected a String returned for the host name - got a crash.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An unexpected exception has been detected in native code outside the VM.
      Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D214901
      Function=JNU_NewStringPlatform+0x1F9
      Library=C:\Program Files\Java\j2re1.4.1_01\bin\java.dll
      Current Java thread:
      at java.net.Inet4AddressImpl.getHostByAddr(Native Method)
      at java.net.InetAddress$1.getHostByAddr(InetAddress.java:722)
      at java.net.InetAddress.getHostFromNameService(InetAddress.java:464)
      at java.net.InetAddress.getHostName(InetAddress.java:407)
      at java.net.InetAddress.getHostName(InetAddress.java:379)
      at LogScanner.main(LogScanner.java:37)

      Dynamic libraries:
      0x00400000 - 0x00406000 C:\WINDOWS\system32\java.exe
      0x77F50000 - 0x77FF7000 C:\WINDOWS\System32\ntdll.dll
      0x77E60000 - 0x77F46000 C:\WINDOWS\system32\kernel32.dll
      0x77DD0000 - 0x77E5D000 C:\WINDOWS\system32\ADVAPI32.dll
      0x78000000 - 0x78086000 C:\WINDOWS\system32\RPCRT4.dll
      0x77C10000 - 0x77C63000 C:\WINDOWS\system32\MSVCRT.dll
      0x6D330000 - 0x6D45A000 C:\Program


      Files\Java\j2re1.4.1_01\bin\client\jvm.dll
      0x77D40000 - 0x77DCC000 C:\WINDOWS\system32\USER32.dll
      0x77C70000 - 0x77CB0000 C:\WINDOWS\system32\GDI32.dll
      0x76B40000 - 0x76B6C000 C:\WINDOWS\system32\WINMM.dll
      0x76390000 - 0x763AC000 C:\WINDOWS\System32\IMM32.DLL
      0x629C0000 - 0x629C8000 C:\WINDOWS\system32\LPK.DLL
      0x72FA0000 - 0x72FFA000 C:\WINDOWS\system32\USP10.dll
      0x6D1D0000 - 0x6D1D7000 C:\Program Files\Java\j2re1.4.1_01\bin\hpi.dll
      0x6D300000 - 0x6D30D000 C:\Program Files\Java\j2re1.4.1_01\bin\verify.dll
      0x6D210000 - 0x6D229000 C:\Program Files\Java\j2re1.4.1_01\bin\java.dll
      0x6D320000 - 0x6D32D000 C:\Program Files\Java\j2re1.4.1_01\bin\zip.dll
      0x6D2D0000 - 0x6D2DE000 C:\Program Files\Java\j2re1.4.1_01\bin\net.dll
      0x71AD0000 - 0x71AD8000 C:\WINDOWS\system32\WSOCK32.dll
      0x71AB0000 - 0x71AC5000 C:\WINDOWS\system32\WS2_32.dll
      0x71AA0000 - 0x71AA8000 C:\WINDOWS\system32\WS2HELP.dll
      0x71A50000 - 0x71A8B000 C:\WINDOWS\System32\mswsock.dll
      0x76F20000 - 0x76F45000 C:\WINDOWS\system32\DNSAPI.dll
      0x76FB0000 - 0x76FB7000 C:\WINDOWS\System32\winrnr.dll
      0x76F60000 - 0x76F8C000 C:\WINDOWS\system32\WLDAP32.dll
      0x76FC0000 - 0x76FC5000 C:\WINDOWS\system32\rasadhlp.dll
      0x76C90000 - 0x76CB2000 C:\WINDOWS\system32\imagehlp.dll
      0x6D510000 - 0x6D58D000 C:\WINDOWS\system32\DBGHELP.dll
      0x77C00000 - 0x77C07000 C:\WINDOWS\system32\VERSION.dll
      0x76BF0000 - 0x76BFB000 C:\WINDOWS\system32\PSAPI.DLL

      Local Time = Wed Jan 08 13:02:54 2003
      Elapsed Time = 109
      #
      # The exception above was detected in native code outside the VM
      #
      # Java VM: Java HotSpot(TM) Client VM (1.4.1_01-b01 mixed mode)
      #
      # An error report file has been saved as hs_err_pid2280.log.
      # Please refer to the file for further information.
      #

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      // give this a access.log file from an apache web server as the first arg..
      import java.io.*;
      import java.net.*;
      public class LogScanner
      {
      public static void main(String[] args) throws Exception
      {
      BufferedReader in = new BufferedReader( new InputStreamReader( new
      FileInputStream(args[0]) ) );
      HashSet visitors = new HashSet();
      String line;
      while( (line = in.readLine()) != null )
      {
      String ip = line.substring(0,line.indexOf(' '));
      visitors.add(ip);
      }
      in.close();
      System.out.println("Visits from "+visitors.size()+" unique IPs.");
      Iterator it = visitors.iterator();
      while( it.hasNext() )
      {
      try
      {
      String ip = it.next().toString();
      InetAddress addr = InetAddress.getByName( ip );
      String hostName = addr.getHostName(); // getCanonicalHostName();
      System.out.println( hostName );
      } catch( UnknownHostException e )
      {
      System.out.println("unknown host");
      }
      }
      }
      }
      ---------- END SOURCE ----------
      (Review ID: 179761)
      ======================================================================

      Name: rmT116609 Date: 01/09/2003


       DESCRIPTION OF THE PROBLEM :
      The Java VM crashes completely on a call to java.net.InetAddress.getByName(String host) when the given IP address has no address (A) record in the DNS. One address that does not have an A record is for example "66.28.187.250".


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Call the method InetAddress.getByName(String host) with a host given as an IP address. The host of the address should not have a A record in the DNS to cause the JVM to crash.

      A call that crashes for me is:
      InetAddress.getByName("66.28.187.250");

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      For me (using the DNS here at sics.se) I get a crash each and every time.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An unexpected exception has been detected in native code outside the VM.
      Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D2148B8
      Function=JNU_NewStringPlatform+0x1F9
      Library=C:\Program Files\Java\j2re1.4.0_01\bin\java.dll

      Current Java thread:
              at java.net.Inet4AddressImpl.getHostByAddr(Native Method)
              at java.net.InetAddress$1.getHostByAddr(InetAddress.java:718)
              at java.net.InetAddress.getHostFromNameService(InetAddress.java:464)
              at java.net.InetAddress.getHostName(InetAddress.java:407)
              at java.net.InetAddress.getHostName(InetAddress.java:379)
              at Test.main(Test.java:6)

      Dynamic libraries:
      0x00400000 - 0x00406000 c:\WINDOWS\system32\java.exe
      0x77F50000 - 0x77FF9000 C:\WINDOWS\System32\ntdll.dll
      0x77E60000 - 0x77F45000 C:\WINDOWS\system32\kernel32.dll
      0x77DD0000 - 0x77E5B000 C:\WINDOWS\system32\ADVAPI32.dll
      0x77CC0000 - 0x77D35000 C:\WINDOWS\system32\RPCRT4.dll
      0x77C10000 - 0x77C63000 C:\WINDOWS\system32\MSVCRT.dll
      0x6D330000 - 0x6D445000 C:\Program Files\Java\j2re1.4.0_01
      \bin\client\jv
      m.dll
      0x77D40000 - 0x77DC6000 C:\WINDOWS\system32\USER32.dll
      0x77C70000 - 0x77CB0000 C:\WINDOWS\system32\GDI32.dll
      0x76B40000 - 0x76B6C000 c:\WINDOWS\system32\WINMM.dll
      0x76390000 - 0x763AA000 C:\WINDOWS\System32\IMM32.DLL
      0x629C0000 - 0x629C8000 c:\WINDOWS\system32\LPK.DLL
      0x72FA0000 - 0x72FFA000 c:\WINDOWS\system32\USP10.dll
      0x6D1D0000 - 0x6D1D7000 C:\Program Files\Java\j2re1.4.0_01\bin\hpi.dll
      0x6D300000 - 0x6D30D000 C:\Program Files\Java\j2re1.4.0_01
      \bin\verify.dl
      l
      0x6D210000 - 0x6D228000 C:\Program Files\Java\j2re1.4.0_01\bin\java.dll
      0x6D320000 - 0x6D32D000 C:\Program Files\Java\j2re1.4.0_01\bin\zip.dll
      0x6D2D0000 - 0x6D2DD000 C:\Program Files\Java\j2re1.4.0_01\bin\net.dll
      0x71AD0000 - 0x71AD8000 c:\WINDOWS\system32\WSOCK32.dll
      0x71AB0000 - 0x71AC5000 c:\WINDOWS\system32\WS2_32.dll
      0x71AA0000 - 0x71AA8000 c:\WINDOWS\system32\WS2HELP.dll
      0x71A50000 - 0x71A8B000 C:\WINDOWS\System32\mswsock.dll
      0x76F20000 - 0x76F45000 c:\WINDOWS\system32\DNSAPI.dll
      0x76FB0000 - 0x76FB7000 C:\WINDOWS\System32\winrnr.dll
      0x76F60000 - 0x76F8C000 C:\WINDOWS\system32\WLDAP32.dll
      0x76C90000 - 0x76CB2000 C:\WINDOWS\system32\imagehlp.dll
      0x6D510000 - 0x6D58C000 C:\WINDOWS\system32\DBGHELP.dll
      0x77C00000 - 0x77C07000 C:\WINDOWS\system32\VERSION.dll
      0x76BF0000 - 0x76BFB000 c:\WINDOWS\system32\PSAPI.DLL

      Local Time = Wed Jan 08 20:28:11 2003
      Elapsed Time = 1
      #
      # The exception above was detected in native code outside the VM
      #
      # Java VM: Java HotSpot(TM) Client VM (1.4.0_01-b03 mixed mode)
      #
      # An error report file has been saved as hs_err_pid3732.log.
      # Please refer to the file for further information.
      #


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.net.InetAddress;
      public class Test {
        public static void main(String[] args) throws Exception {
          InetAddress adr = InetAddress.getByName("66.28.187.250");
          System.out.println("Name: " + adr.getHostName());
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      Do not try to lookup IP addresses using this call (this can be hard since it actually is called by a lot of the built-in permission checks for the java.net package...)
      (Review ID: 179763)
      ======================================================================

            michaelm Michael McMahon
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: