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

Connecting via RDP can crash the JVM if client AWT is active

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11 Pro 21H2 22000.556

      Crash occurs with Java versions:
      OpenJDK JDK 25 Release-Candidate 25+36-3489
      Oracle JDK 24.0.2+12-54
      Oracle JDK 23.0.2+7-58
      Temurin-24.0.2+12
      Temurin-21.0.6+7
      Temurin-17.0.14+7

      The crash does not occur with
      Oracle JDK-21.0.8+12-LTS-250
      Termium-21.0.8+9-LTS

      A DESCRIPTION OF THE PROBLEM :
      The JVM will crash inside native code (awt.dll) when a workstation that is running active awt code is attached from a RDP client. The crash happens immediately. I assume that the crash occurs as the graphics configuration is changing while awt is busy drawing.

      This crash occurs with recent 23, 24 and 25 versions of the JDK, but curiously it does not seem to occur when using Oracle JDK-21.0.8+12-LTS-250 or Termium-21.0.8+9-LTS.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      To reproduce this problem you will need 2 Windows workstations. One to run the SSCE program, the other establish an RDP connection to the first workstation.
      1) Start the attached SSCE program on workstation #1
      2) From workstation #2, connect to workstation #1 using the "Remote Desktop Connection" application.
      The crash will happen immediately without needing to do anything else.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected that the SSCE program would continue to run successfully after the RDP connection was made.
      ACTUAL -
      The JVM crashed within native code in awt.dll. The first part of the crash report from the most recent OpenJDK version (25+36-3489) looks like the attached crash_info.txt file.

      ---------- BEGIN SOURCE ----------

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.util.Random;

      /**
       * Program to continuously draw to the screen. Used to test what happens
       * when an RDP connection is made and the window dimension is resized.
       */
      public class BusyWindow extends JFrame implements Runnable {

          Random rand;
          Graphics2D g2d;

          public BusyWindow() {
              setTitle("Keep drawing");
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              getContentPane().setLayout(new BorderLayout());

              JPanel canvas = new JPanel();
              canvas.setToolTipText("A very busy canvas");
              getContentPane().add(canvas, BorderLayout.CENTER);

              setSize(new Dimension(500, 500));
              setVisible(true);

              rand = new Random();
              g2d = (Graphics2D) canvas.getGraphics();

              SwingUtilities.invokeLater(this);
          }

          @Override
          public void run() {
              int width = getWidth();
              int height = getHeight();
              g2d.setPaint(Color.WHITE);
              g2d.fillRect(0,0, width, height);
              for (int i=0; i<20; i++) {
                  int x = rand.nextInt(width);
                  int y = rand.nextInt(height);
                  int w = rand.nextInt(100);
                  int h = rand.nextInt(100);
                  Color c = new Color(rand.nextInt(16777216));
                  int op = rand.nextInt(4);
                  g2d.setPaint(c);
                  if (op == 0)
                      g2d.fillOval(x, y, w, h);
                  else if (op == 1)
                      g2d.fillRect(x, y, w, h);
                  else if (op == 2)
                      g2d.fillRoundRect(x, y, w, h, 10, 10);
                  else
                      g2d.drawString("Busy", x, y);
              }
              SwingUtilities.invokeLater(this);
          }

          public static void main(String[] args) {
              SwingUtilities.invokeLater(BusyWindow::new);
          }
      }

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

        1. BusyWindow.java
          2 kB
          Patricia Tavares
        2. crash_info.txt
          4 kB
          Patricia Tavares
        3. hs_err_pid13024.log
          143 kB
          Patricia Tavares

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: