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

java.net.ServerSocket fails with core

    XMLWordPrintable

Details

    • sparc
    • solaris_2.5.1

    Description



      Name: dfC67450 Date: 05/11/99



      java.net.ServerSocket fails with core after being in idle state during
      more than 15 minutes. Idle state is the state when no clients are connected
      to this server. For work with new connection server creates new thread which
      writes into outputstream "Hi Amigo" and prints everything from inputstream.

      Example of client in Client.java.
      It connects to server, reads something from server and writes "Hello".
      Then client disconnects. To run client you should pass to it 2 parameters:
      host name and port number.

      To reproduce the bug do the following:

      1. run server for example on 'spb' with command: java Server
      2. run client in another console with command: java Client spb 0xfda0
      3. wait for 15 minutes
      4. repeat #2, server will fail with core.


      -----------------Server.java------------------------
      import java.net.ServerSocket;
      import java.net.Socket;
      import java.net.InetAddress;
      import java.io.IOException;
      import java.io.InputStream;
      import java.io.OutputStream;

      public class Server extends ServerSocket {

          public int port = 0;

          public static void main (String args[]) {
              try {
                  Server server = new Server(0xFDA0);
                  server.go();
              } catch (IOException e) {
                  System.out.println("Error of server initialization: " + e);
              }
              return;
          }

          public Server(int port) throws IOException {
              super(port);
              this.port = getLocalPort();
              System.out.println("--- port: " + this.port + " ---");
          }

          public void go() {
              while (true) {
                  try {
                      Socket sock = accept();
                      Dialog d = new Dialog(this, sock);
                      System.out.println(" -- address: " + sock.getInetAddress());
                      d.start();
                  } catch (IOException e) {
                      System.out.println("unexpected ): " + e);
                  }
              }
          }
      }

      class Dialog extends Thread {

          Socket socket = null;
          Server server = null;
          InputStream in = null;
          OutputStream out = null;


          public Dialog (Server server,
                         Socket sock) throws IOException {
              this.server = server;
              this.socket = sock;
              try {
                  in = socket.getInputStream();
                  out = socket.getOutputStream();
              } catch (IOException e) {
                  throw new IOException("error with open stream: " + e.toString());
              }
          }
          
          public void run() {
              System.out.println("== new client connected == ");
              try {
                  out.write("Hi Amigo".getBytes());
                  int len = 0;
                  while (len >= 0) {
                      byte[] bytes = new byte[80];
                      len = in.read(bytes);
                      if (len > 0) System.out.println(new String(bytes, 0, len));
                  }
                  in.close();
                  out.close();
              } catch (IOException e) {
                  System.out.println("Thread thrown an exception " + e);
                  System.out.println("And will be interrupted");
                  e.printStackTrace(System.out);
              }
              System.out.println("== client disconnected == ");

          }
      }

      -----------------Client.java------------------------
      import java.net.ServerSocket;
      import java.net.Socket;
      import java.net.InetAddress;
      import java.net.MalformedURLException;
      import java.io.IOException;
      import java.io.InputStream;
      import java.io.OutputStream;

      public class Client {
          public int port = 0;
          public String host = null;
          OutputStream out = null;
          InputStream in = null;

          String name = null;

          public static void main (String args[]){
              String host = args[0];
              int port = Integer.decode(args[1]).intValue();
              Client client = new Client(host, port);
              client.go();
          }

          public Client(String host, int port) {
              this.host = host;
              this.port = port;
          }

          public void go() {
              try {
                  Socket sock = new Socket(host, port);
                  out = sock.getOutputStream();
                  in = sock.getInputStream();
                  byte[] bytes = new byte[80];
                  int len = in.read(bytes);
                  if (len > 0)
                      System.out.println("received: " + new String(bytes, 0, len));
                  out.write("Hello".getBytes());
              } catch (Exception e) {
                   System.out.println("exception: " + e);
              }
              
          }
      }

      ---------Output of Server ---------------------
      <spb> showrev -p
      Patch: 103630-13 Obsoletes: Packages: SUNWcsu, SUNWcsr
      Patch: 103663-14 Obsoletes: 103683-01 Packages: SUNWcsu, SUNWcsr, SUNWhea
      Patch: 103582-18 Obsoletes: Packages: SUNWcsu, SUNWcsr
      Patch: 103594-16 Obsoletes: 105520-01 Packages: SUNWcsu, SUNWcsr, SUNWnisu
      Patch: 103603-09 Obsoletes: Packages: SUNWcsu
      Patch: 103612-46 Obsoletes: 103615-04, 103654-01 Packages: SUNWcsu, SUNWcsr, SUNWarc, SUNWscpu, SUNWfns, SUNWnisu, SUNWsra, SUNWsutl
      Patch: 103622-12 Obsoletes: Packages: SUNWcsu, SUNWcsr, SUNWhea
      Patch: 103627-05 Obsoletes: 103606-02, 105069-01 Packages: SUNWcsu, SUNWcsr, SUNWarc, SUNWbtool, SUNWhea, SUNWtoo, SUNWxcu4
      Patch: 103640-23 Obsoletes: 103591-09, 103658-02, 103920-05, 103600-18, 103609-02 Packages: SUNWcsu, SUNWcsr, SUNWkvm, SUNWcar, SUNWhea
      Patch: 103680-02 Obsoletes: Packages: SUNWcsu
      Patch: 103690-06 Obsoletes: Packages: SUNWcsu
      Patch: 103696-04 Obsoletes: Packages: SUNWcsu, SUNWcsr
      Patch: 103699-02 Obsoletes: Packages: SUNWcsu
      Patch: 103817-02 Obsoletes: Packages: SUNWcsu
      Patch: 103934-08 Obsoletes: Packages: SUNWcsu, SUNWcsr, SUNWhea
      Patch: 104166-03 Obsoletes: Packages: SUNWcsu
      Patch: 104220-03 Obsoletes: Packages: SUNWcsu
      Patch: 104266-01 Obsoletes: Packages: SUNWcsu
      Patch: 104317-01 Obsoletes: Packages: SUNWcsu
      Patch: 104331-07 Obsoletes: Packages: SUNWcsu
      Patch: 104433-07 Obsoletes: Packages: SUNWcsu, SUNWcsr
      Patch: 104490-05 Obsoletes: 103847-02 Packages: SUNWcsu
      Patch: 104334-01 Obsoletes: Packages: SUNWcsu
      Patch: 104613-01 Obsoletes: Packages: SUNWcsu
      Patch: 104650-02 Obsoletes: Packages: SUNWcsu
      Patch: 104654-05 Obsoletes: Packages: SUNWcsu
      Patch: 104692-01 Obsoletes: Packages: SUNWcsu
      Patch: 104708-14 Obsoletes: 104710-01, 103766-02 Packages: SUNWcsu, SUNWhea, SUNWssadv, SUNWssaop
      Patch: 104736-04 Obsoletes: Packages: SUNWcsu
      Patch: 104776-02 Obsoletes: Packages: SUNWcsu, SUNWarc
      Patch: 104935-01 Obsoletes: Packages: SUNWcsu
      Patch: 103738-08 Obsoletes: Packages: SUNWcsu
      Patch: 104956-04 Obsoletes: Packages: SUNWcsu
      Patch: 104958-01 Obsoletes: Packages: SUNWcsu
      Patch: 104960-01 Obsoletes: Packages: SUNWcsu
      Patch: 104968-02 Obsoletes: Packages: SUNWcsu
      Patch: 105050-01 Obsoletes: Packages: SUNWcsu, SUNWscpu
      Patch: 105092-01 Obsoletes: Packages: SUNWcsu
      Patch: 105784-02 Obsoletes: Packages: SUNWcsu, SUNWarc
      Patch: 103981-14 Obsoletes: Packages: SUNWcsu, SUNWcsr
      Patch: 103597-04 Obsoletes: Packages: SUNWcsr
      Patch: 104283-04 Obsoletes: Packages: SUNWcsr
      Patch: 104560-05 Obsoletes: Packages: SUNWcsr
      Patch: 104893-01 Obsoletes: Packages: SUNWcsr
      Patch: 105004-10 Obsoletes: 104604-04 Packages: SUNWcsr, SUNWcar, SUNWhea
      Patch: 105299-01 Obsoletes: Packages: SUNWcsr
      Patch: 105352-01 Obsoletes: Packages: SUNWcsr
      Patch: 104795-02 Obsoletes: Packages: SUNWkvm
      Patch: 104595-06 Obsoletes: Packages: SUNWkvm
      Patch: 104489-08 Obsoletes: Packages: SUNWtltk, SUNWtltkd
      Patch: 103566-36 Obsoletes: 103508-01 Packages: SUNWxwfnt, SUNWxwplt, SUNWxwopt, SUNWxwslb
      Patch: 104338-02 Obsoletes: Packages: SUNWxwplt, SUNWxwslb
      Patch: 104010-01 Obsoletes: Packages: SUNWvolu
      Patch: 104841-03 Obsoletes: Packages: SUNWvolu
      Patch: 106382-01 Obsoletes: Packages: SUNWvolu
      Patch: 103901-11 Obsoletes: Packages: SUNWolrte, SUNWolinc, SUNWolslb
      Patch: 104533-04 Obsoletes: Packages: SUNWolrte, SUNWolslb
      Patch: 104976-03 Obsoletes: Packages: SUNWoldcv, SUNWoldst
      Patch: 103461-27 Obsoletes: Packages: SUNWmfrun
      Patch: 103558-12 Obsoletes: Packages: SUNWadmap, SUNWadmc, SUNWsadml
      Patch: 106224-01 Obsoletes: Packages: SUNWoldst
      Patch: 103879-04 Obsoletes: Packages: SUNWkcsrt
      Patch: 104516-03 Obsoletes: Packages: SUNWapppu
      Patch: 103959-08 Obsoletes: Packages: SUNWscpu, SUNWlpr, SUNWlpu, SUNWlps
      Patch: 103866-05 Obsoletes: Packages: SUNWbcp
      Patch: 103743-01 Obsoletes: Packages: SUNWfns
      Patch: 104605-08 Obsoletes: Packages: SUNWhea
      Patch: 103686-02 Obsoletes: Packages: SUNWnisu
      Patch: 105344-01 Obsoletes: Packages: SUNWtoo
      Patch: 103900-01 Obsoletes: Packages: SUNWowbcp
      Patch: 105251-01 Obsoletes: Packages: SUNWowbcp
      Patch: 105789-02 Obsoletes: 103796-19 Packages: SUNWvlxil
      Patch: 103801-07 Obsoletes: Packages: SUNWsprot, SUNWxcu4t

      <spb> showrev -p |grep -c Patch
      73

      <spb> uname -a
      SunOS spb 5.5.1 Generic_103640-23 sun4u sparc SUNW,Ultra-1

      <spb> java -version
      java version "1.3"
      Classic VM (build JDK-1.3-C, green threads, sunwjit)

      <spb> java Server
      --- port: 64928 ---
       -- address: spb.sparc.spb.su/192.168.205.170
      == new client connected ==
      Hello
      == client disconnected ==
      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_MAPERR [addr: 0xFA066014]
       
              stackpointer=efffe8f8
       
      Full thread dump Classic VM (JDK-1.3-C, green threads):
          "Finalizer" (TID:0xebc98308, sys_thread_t:0x61500, state:CW) prio=8
              at java.lang.Object.wait(Native Method)
              at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:112)
              at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
              at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:174)
          "Reference Handler" (TID:0xebc98398, sys_thread_t:0x5dd98, state:CW) prio=10
              at java.lang.Object.wait(Native Method)
              at java.lang.Object.wait(Object.java:424)
              at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:114)
          "Signal dispatcher" (TID:0xebc983c8, sys_thread_t:0x582b8, state:CW) prio=5
          "main" (TID:0xebc981c8, sys_thread_t:0x26810, state:R) prio=5
              at Server.go(Server.java, Compiled Code)
              at Server.main(Server.java, Compiled Code)
      Monitor Cache Dump:
          java.lang.ref.ReferenceQueue$Lock@EBC98320/EBCCE028: <unowned>
              Waiting to be notified:
                  "Finalizer" (0x61500)
          java.lang.Class@EBCBF570/EBD913A8: owner "main" (0x26810) 1 entry
          sun.misc.Launcher$AppClassLoader@EBC993F0/EBCE05E8: owner "main" (0x26810) 1 entry
          java.lang.ref.Reference$Lock@EBC983A8/EBCCDB20: <unowned>
              Waiting to be notified:
                  "Reference Handler" (0x5dd98)
      Registered Monitor Dump:
          PCMap lock: <unowned>
          utf8 hash table: <unowned>
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class linking lock: <unowned>
          System class loader lock: <unowned>
          Code rewrite lock: <unowned>
          Heap lock: <unowned>
          Monitor cache lock: owner "main" (0x26810) 1 entry
          Dynamic loading lock: <unowned>
          Monitor IO lock: <unowned>
          User signal monitor: <unowned>
              Waiting to be notified:
                  "Signal dispatcher" (0x582b8)
          Child death monitor: <unowned>
          I/O monitor: <unowned>
          Alarm monitor: <unowned>
              Waiting to be notified:
                  <unknown thread> (0x2bb00)
          Thread queue lock: owner "main" (0x26810) 1 entry
          Monitor registry: owner "main" (0x26810) 1 entry
       
      SIGABRT 6* abort (generated by abort(3) routine)
          si_signo [6]: SIGABRT 6* abort (generated by abort(3) routine)
          si_errno [0]: Error 0
          si_code [0]: SI_USER [pid: 18489, uid: 314]
              stackpointer=efffe8f8
       
      Full thread dump Classic VM (JDK-1.3-C, green threads):
          "Finalizer" (TID:0xebc98308, sys_thread_t:0x61500, state:CW) prio=8
              at java.lang.Object.wait(Native Method)
              at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:112)
              at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
              at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:174)
          "Reference Handler" (TID:0xebc98398, sys_thread_t:0x5dd98, state:CW) prio=10
              at java.lang.Object.wait(Native Method)
              at java.lang.Object.wait(Object.java:424)
              at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:114)
          "Signal dispatcher" (TID:0xebc983c8, sys_thread_t:0x582b8, state:CW) prio=5
          "main" (TID:0xebc981c8, sys_thread_t:0x26810, state:R) prio=5
              at Server.go(Server.java, Compiled Code)
              at Server.main(Server.java, Compiled Code)
      Monitor Cache Dump:
          java.lang.ref.ReferenceQueue$Lock@EBC98320/EBCCE028: <unowned>
              Waiting to be notified:
                  "Finalizer" (0x61500)
          java.lang.Class@EBCBF570/EBD913A8: owner "main" (0x26810) 1 entry
          sun.misc.Launcher$AppClassLoader@EBC993F0/EBCE05E8: owner "main" (0x26810) 1 entry
          java.lang.ref.Reference$Lock@EBC983A8/EBCCDB20: <unowned>
              Waiting to be notified:
                  "Reference Handler" (0x5dd98)
      Registered Monitor Dump:
          PCMap lock: <unowned>
          utf8 hash table: <unowned>
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class linking lock: <unowned>
          System class loader lock: <unowned>
          Code rewrite lock: <unowned>
          Heap lock: <unowned>
          Monitor cache lock: owner "main" (0x26810) 1 entry
          Dynamic loading lock: <unowned>
          Monitor IO lock: <unowned>
          User signal monitor: <unowned>
              Waiting to be notified:
                  "Signal dispatcher" (0x582b8)
          Child death monitor: <unowned>
          I/O monitor: <unowned>
          Alarm monitor: <unowned>
              Waiting to be notified:
                  <unknown thread> (0x2bb00)
          Thread queue lock: owner "main" (0x26810) 1 entry
          Monitor registry: owner "main" (0x26810) 1 entry


      --------- Output of Client ---------------------
      <spb> java Client spb 0xfda0
      received: Hi Amigo

      <spb> java Client spb 0xfda0

      <spb>
      --------------------------------------------------

      ======================================================================

      Attachments

        Activity

          People

            ywangsunw Yingxian Wang (Inactive)
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: