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

SSLStreams doClosure() deadlock in server thread if connection is lost

    XMLWordPrintable

Details

    • x86_64
    • windows_10

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10, Java 11.0.10

      A DESCRIPTION OF THE PROBLEM :
      When client (at least VLC media player) doesn't wait for incoming stream to finish, server thread is deadlocked in doClosure() function forever with high CPU usage

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Server init:

      SSLContext sslContext = SSLContext.getInstance("TLS");
      KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
      kmf.init(trustStore, password);
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(trustStore);
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
      HttpsServer server = HttpsServer.create();

      server.setHttpsConfigurator(new HttpsConfigurator(sslContext) {
      public void configure(HttpsParameters params) {
      try {
      SSLContext c = SSLContext.getDefault();
      SSLEngine engine = c.createSSLEngine();
      params.setNeedClientAuth(false);
      params.setCipherSuites(engine.getEnabledCipherSuites());
      params.setProtocols(engine.getEnabledProtocols());
      SSLParameters defaultSSLParameters = c.getDefaultSSLParameters();
      params.setSSLParameters(defaultSSLParameters);
      } catch (Exception ex) {

      }
      }
      });

      server.bind(new InetSocketAddress(8080, 0);
      ExecutorService executor = Executors.newFixedThreadPool(30);
      server.setExecutor(executor);

      Context code:
      exchange.sendResponseHeaders(200, srcFile.length());
      Files.copy(srcFile.toPath(), exchange.getResponseBody());
      exchange.getResponseBody().flush();
      exchange.getResponseBody().close();

      ACTUAL -
      Each new connection, that is initiated by client before waiting for previous file to transmit, causes deadlock in doClosure with r.result = OK forever, even after client is disconnected long time ago

      void doClosure () throws IOException {
              try {
                  handshaking.lock();
                  ByteBuffer tmp = allocate(BufType.APPLICATION);
                  WrapperResult r;
                  do {
                      tmp.clear();
                      tmp.flip ();
                      r = wrapper.wrapAndSendX (tmp, true);
                  } while (r.result.getStatus() != Status.CLOSED);
              } finally {
                  handshaking.unlock();
              }
          }

      CUSTOMER SUBMITTED WORKAROUND :
      jdk.tls.disabledAlgorithms=TLSv1.3 same workaround as for JDK-8241054

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              michaelm Michael McMahon
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: