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

JPDA Debuggee waiting for input on System.in will prevent ServerSocket creation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 1.3.0
    • core-svc
    • x86
    • windows_2000



      Name: boT120536 Date: 01/25/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


      Processes launched using JPDA that wait for input on System.in will prevent
      other threads from successfully creating a new ServerSocket instance. This is
      reproducable on Windows 2000 with SP1 installed. Stranglely, this problem does
      not occur on machines without SP1 installed. We have received reports that this
      problem exists also in Win98 but we have been unable to find the exact
      conditions to reproduce this problem on Win98.

      This problem makes it very difficult to debug processes such as server programs
      that often wait for commands on System.in.

        To reproduce, please attempt to run the following program from within jdb and
      you will notice that the ServerSocket constructor never returns (the
      string "ServerSocket created" is never printed to console). Displaying a stack
      trace for the blocked thread indicates that it is stuck in a native method call.

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

      class Test
      {
          public static void main(String[] args) {
              MyThread thread = new MyThread();
              thread.start();
              
              try {
                  Thread.sleep(2000);
              } catch (InterruptedException e) {
                  System.out.println(e);
              }
              
              System.out.println("Creating ServerSocket");
              try {
                  ServerSocket server = new ServerSocket(0);
                  // thread never returns from above call
                  
                  System.out.println("ServerSocket created");
                  Socket client = server.accept();
              } catch (IOException e) {
                  System.out.println(e);
              }
          }
          
          static class MyThread extends Thread {
              public void run() {
                  try {
                      System.out.println("Waiting for input");
                      BufferedReader br = new BufferedReader(
                                          new InputStreamReader(System.in));
                      String input = br.readLine();
                      System.out.println("Enter: " + input);
                  } catch (IOException e) {
                      System.out.println(e);
                  }
                  System.exit(0);
              }
          }
      }
      (Review ID: 111299)
      ======================================================================

            tbell Tim Bell
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: