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

Windows Vista socke read hangs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 7-pool
    • 7, 7u5
    • core-libs
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

      FULL OS VERSION :
      Microsoft Windows [Version 6.1.7601]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      WiFi connection - Intel WiFi Link 1000 BGN, Driver version 14.1.1.3 (2011-05-01)

      A DESCRIPTION OF THE PROBLEM :
      When downloading anything from the remote URL method java.net.URL.url.openStream() followed by InputStream.read(byte[]) hangs:

      "main" prio=6 tid=0x0000000001edb000 nid=0xe14 runnable [0x000000000200f000]
         java.lang.Thread.State: RUNNABLE
              at java.net.SocketInputStream.socketRead0(Native Method)
              at java.net.SocketInputStream.read(SocketInputStream.java:150)
              at java.net.SocketInputStream.read(SocketInputStream.java:121)
              at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
              at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
              - locked <0x00000000eb31dd68> (a java.io.BufferedInputStream)
              at sun.net.www.MeteredStream.read(MeteredStream.java:134)
              - locked <0x00000000eb320b58> (a sun.net.www.http.KeepAliveStream)
              at java.io.FilterInputStream.read(FilterInputStream.java:133)
              at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2968)
              at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
              at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
              at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
              - locked <0x00000000eb2fc500> (a java.io.BufferedInputStream)
              at java.io.FilterInputStream.read(FilterInputStream.java:107)
              at io.DownloadJar.main(DownloadJar.java:20)

      I can provide you with Windows process dump (DMP) as well as full thread dump if needed.

      What is absolutely crazy about this bug is that on Ubuntu that I run on VirtualBox on the very same machine it works 100% of the time.

      I suspect a bug in Windows JVM native code.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run simple program provided below under Windows 7.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      This program will very often hang before downloading the full contents of netty-3.2.6.Final.jar
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no error messages - this program just hangs

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      package io;

      import java.io.BufferedInputStream;
      import java.io.BufferedOutputStream;
      import java.io.FileOutputStream;
      import java.io.IOException;
      import java.net.MalformedURLException;
      import java.net.URL;

      public class DownloadJar {

      public static void main(String[] args) throws MalformedURLException {
      URL url = new URL("http://repo1.maven.org/maven2/org/jboss/netty/netty/3.2.6.Final/netty-3.2.6.Final.jar");
      try (BufferedInputStream in = new BufferedInputStream(url.openStream());
      BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("netty.jar"))) {

      byte[] buf = new byte[2048];
      int len = 0;
      int total = 0;
      while ((len = in.read(buf)) > 0) {
      total += len;
      System.out.println(total / 1024 + "KB");
      out.write(buf, 0, len);
      }
      } catch (IOException e) {
      e.printStackTrace();
      }
      }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      unknown
      This bug can be reproduced under following environment:

      FULL PRODUCT VERSION :
      java version "1.7.0_05"
      Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      Unless using the -Djava.net.preferIPv4Stack=true, otherwise it hangs every time.

      Another way to reproduce is to run a Tomcat unit test

      1. svn co http://svn.apache.org/repos/asf/tomcat/trunk
      2. cd trunk
      3. [with java 6] ant
      4. [with java 7] ant -Dtest.entry=org.apache.catalina.connector.TestSendFile test-bio test-nio

      Work arounds are
      a) Use Java 6
      b) Use -Djava.net.preferIPv4Stack=true when using Java 7

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: