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

Lingering on Java 1.8.0_66 Applet breakpoints causes crash

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java -version
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      Java HotSpot(TM) Client VM (build 25.66-b17, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The applet is being run in Internet Explorer 11, Version 11.0.9600.18015, Update Versions 11.0.23 (KB3087038) and in Firefox 41.0.2.
      I am using the 32 bit Java 1.8.0_66 on a 64 bit Windows 7 OS.

      A DESCRIPTION OF THE PROBLEM :
      (1) Start an applet in Internet Explorer or Firefox with the command line options in your AppData\LocalLow\Sun\Java\Deployment\deployment.properties for attaching a debugger.
      (2) Put a breakpoint in the code.
      (3) Do whatever is necessary to cause your debugger to stop at the breakpoint.
      (4) Wait about 8 seconds and the Applet crashes.


      REGRESSION. Last worked in version 6u43

      ADDITIONAL REGRESSION INFORMATION:
      I don't know when this last worked. Since it's not possible to choose the version of Java running a Applet anymore without uninstalling more recent versions I really can't tell you when it worked. I think it's pretty safe to assume that it worked in Java 1.4.2 though and probably early versions of Java 1.6.0 too. Back when it was easy to create an Applet I'm sure lots of people would have noticed if you couldn't stop at a breakpoint for more than a few seconds. I'm sure I would have noticed.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      (1) Start an applet in Internet Explorer or Firefox with the command line options in your AppData\LocalLow\Sun\Java\Deployment\deployment.properties
      (2) Put a breakpoint in the code.
      (3) Do whatever is necessary to cause your debugger to stop at the breakpoint.
      (4) Wait about 8 seconds till the Applet crashes.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Applet will not crash.
      ACTUAL -
      The Applet crashes and the Java Console closes without any message.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      There are none that appear in the Java Console.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      --- Source for starter page: ---
      <!DOCTYPE html>
      <html>
        <head>
          <title>STARTER NO JNLP Security Test Applet Page</title>
          <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
          </script>
          <script>
            function open_window() {
              window.open("file:///c:/a-Dev/Worksoft/Java-Interface/Java/JIBE/AppInterface/regression-tests/AppletSecurityTest/securityApplet-1_8.html");
            }
          </script>
        </head>
      <!-- -->
        <body onload="open_window()">
          <h1>NO JNLP Security Test Applet STARTER Page</h1>
          <br/>
          <h1>Be sure to allow pop-ups. (Firefox: Tools-&gt;Options-&gt;Content)</h1>
        </body>
      </html>

      ---- Source for applet page: ----
      <!DOCTYPE html>
      <html>
        <head>
          <title>NO JNLP Security Test Applet Page</title>
         <style>
           button {width:120px; height:400px;}
         </style>
          <script>
            // This will not work unless the tab is created through JavaScript. See the securityApplet-Starter-1_8.html
            function close_window() {
              close();
            }
          </script>
        </head>
      <!-- -->
        <body>
          <h1>NO JNLP Security Test Applet Page</h1>
          <script src="https://www.java.com/js/deployJava.js"></script>
          <table><tr><td>
          <script>
             var attributes = {code:'com.worksoft.security.SecurityApplet.class', archive:'securityApplet-1_8.jar', width:600, height:400};
             var parameters = {fontSize:16, permissions:'all-permissions'};
             deployJava.runApplet(attributes, parameters, '1.8');
          </script>
          </td><td>
          <button id="myBtn" onclick="close_window();return false;"}>Close Tab</button>
          </td></tr></table>
        </body>
      </html>

      ---- Source for Applet - NonStandardButten.java ----
      /**
       * Copyright 2014 - 2014 by Worksoft.Inc
       * <p/>
       * Created by GLystad on 8/1/2014.
       */

      package com.worksoft.security;

      import javax.swing.*;
      import java.awt.*;

      public class NonStandardButton extends JButton {


        /**
         * Creates a button with no set text or icon.
         */
        public NonStandardButton () {
          super();
        }

        /**
         * Creates a button where properties are taken from the Action supplied.
         */
        public NonStandardButton (Action a) {
          super(a);
        }

        /**
         * Creates a button with an icon.
         */
        public NonStandardButton (Icon icon) {
          super(icon);
        }

        /**
         * Creates a button with text.
         */
        public NonStandardButton (String text) {
          super(text);
        }

        /**
         * Creates a button with initial text and an icon.
         */
        public NonStandardButton (String text, Icon icon) {
          super(text, icon);
        }

        public String getWhatItSays () {
          return super.getText();
        }

      }

      ---- Applet source - NonStardardLabel.java ----
      /**
       * Copyright 2014 - 2014 by Worksoft.Inc
       * <p/>
       * Created by GLystad on 8/1/2014.
       */

      package com.worksoft.security;

      import javax.swing.*;
      import java.awt.*;

      /**
       * This is a Label but it uses the methods setValue and getValue to do what is normally done
       * by setText and getText respectively. The point is just to be different so we know we're
       * using this class and not something loaded with Java.
       */
      public class NonStandardLabel extends Label {

        /**
         * Creates a Label with no text or icon.
         */
        public NonStandardLabel () {
          super();
        }

        /**
         * Creates a Label with text.
         */
        public NonStandardLabel (String text) {
          super(text);
        }

        public String getText () {
          return null;
        }

        public String getValue () {
          return super.getText();
        }

        public void setText (String val) {
        }

        public void setValue (String val) {
          super.setText(val);
        }

      }

      ---- Applet Source - SecurityApplet.java: ----
      /**
       * Copyright 2014 - 2014 by Worksoft.Inc
       * <p/>
       * Created by GLystad on 8/1/2014.
       */

      package com.worksoft.security;

      import javax.swing.*;
      import java.applet.Applet;
      import java.awt.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.io.*;
      import java.lang.reflect.Method;

      public class SecurityApplet extends JApplet {

        NonStandardButton button1 = new NonStandardButton("1 Class.forName(String)");
        NonStandardButton button2 = new NonStandardButton("2 Class.forName(NonStandardLabel)");
        NonStandardButton button3 = new NonStandardButton("3 getProperty('http.agent')");
        NonStandardButton button4 = new NonStandardButton("4 getProperty(user.home)");
        NonStandardButton button5 = new NonStandardButton("5 Read from <java.home>\\LICENSE");
        NonStandardButton button6 = new NonStandardButton("6 Get Input from JOptionPane.");
        NonStandardButton button7 = new NonStandardButton("7 reserved");
        NonStandardLabel label8 = new NonStandardLabel("");
      // LoggingSecurityManager currentSM_ = null;

        public void start () {
          SecurityApplet pane = this;
          pane.setLayout(new GridLayout(4, 2, 0, 0));
          Color cream = new Color(0xFFFFDD);
          Color labelColor = new Color(0xDDFFDD);
          ButtonListener butler = new ButtonListener();

          pane.add(button1);
          pane.add(button2);
          pane.add(button3);
          pane.add(button4);
          pane.add(button5);
          pane.add(button6);
          pane.add(button7);
          pane.add(label8);

          button1.setBackground(cream);
          button1.addActionListener(butler);
          button2.setBackground(cream);
          button2.addActionListener(butler);
          button3.setBackground(cream);
          button3.addActionListener(butler);
          button4.setBackground(cream);
          button4.addActionListener(butler);
          button5.setBackground(cream);
          button5.addActionListener(butler);
          button6.setBackground(cream);
          button6.addActionListener(butler);
          button7.setBackground(cream);
          button7.addActionListener(butler);
          label8.setBackground(labelColor);
          setSize(600, 400);
          // addWindowListener(new MyWindowListener()); // Defined below.
          setVisible(true);
        }

        private void makeLogEntry (String msg) {
      // if (currentSM_ != null) {
      // currentSM_.makeLogEntry(msg);
      // }
        }

        static public Object sendIfHandles (final Object cc, final String methodStr) {
          try {
            Class ccClass = cc.getClass();
            Method method = null;
            try {
      method = ccClass.getMethod(methodStr, (Class[]) null);
            } catch (Throwable yy) {
            }
            if (method == null) {
      method = getMethodTheHardWay(ccClass, methodStr, (Class[]) null);
            }
            boolean isAccessible = method.isAccessible();
            method.setAccessible(true);
            Object answer = method.invoke(cc, (Object[]) null);
            method.setAccessible(isAccessible);
            return answer;
          } catch (Throwable xx) {
          }
          return null;
        }

        static public Method getMethodTheHardWay (Class claB, String methodStr, final Class[] parmClasses) {
          Method current = null;
          while (claB != null) {
            Method[] methods = claB.getDeclaredMethods();
            METHOD_LOOP:
            for (int index = 0; index < methods.length; index++) {
              current = methods[index];
              if (current.getName().equals(methodStr)) {
                Class[] parmTypes = current.getParameterTypes();
                if ((parmClasses == null || parmClasses.length == 0)) {
                  if (parmTypes.length == 0) {
                    return current;
                  }
                } else if (parmTypes.length == parmClasses.length) {
                  for (int index2 = 0; index2 < parmTypes.length; index2++) {
                    if (parmTypes[index2] != parmClasses[index2]) {
                      continue METHOD_LOOP;
                    }
                  }
                  return current;
                }
              }
            }
            claB = claB.getSuperclass();
          }
          return null;
        }


        public class ButtonListener implements ActionListener {

          public void actionPerformed (ActionEvent evnt) {
            try {
              label8.setValue("");
      Object source = evnt.getSource();
      if (!(source instanceof NonStandardButton)) {
      return;
      }
      String text = ((NonStandardButton)source).getWhatItSays();
      if (text.startsWith("1")) {
      makeLogEntry("Button 1 pressed");
      Object claB = "Error";
      try {
      claB = Class.forName("java.lang.String");
      } catch (Throwable xx) {}
      String name = (claB instanceof Class) ? ((Class)claB).getSimpleName() : claB.toString();
      label8.setValue("Done 1" +" " +name);
      } else if (text.startsWith("2")) {
      makeLogEntry("Button 2 pressed");
      Object claB = "Error";
      try {
      claB = Class.forName("com.worksoft.security.NonStandardLabel");
      } catch (Throwable xx) {}
      String name = (claB instanceof Class) ? ((Class)claB).getSimpleName() : claB.toString();
      label8.setValue("Done 2" +" " +name);
      } else if (text.startsWith("3")) {
      makeLogEntry("Button 3 pressed");
      String pro = "Error";
      try {
      pro = System.getProperty("http.agent");
      } catch (Throwable xx) {}
      label8.setValue("Done 3" +" - " +pro);
      } else if (text.startsWith("4")) {
      makeLogEntry("Button 4 pressed");
      String arch = "Error arch";
      String userHome = "Error user.home";
      try {
      userHome = System.getProperty("user.home");
      arch = System.getProperty("sun.arch.data.model");
      } catch (Throwable yy) {}
      label8.setValue("Done 4" +" - user: " +userHome +"\n bits: " +arch);
      } else if (text.startsWith("5")) {
      makeLogEntry("Button 5 pressed");
      String line = "Error";
      BufferedReader inputLines = null;
      try {
      String filename = System.getProperty("java.home") +System.getProperty("file.separator") +"LICENSE";
      inputLines = new BufferedReader(new FileReader(filename));
      line = inputLines.readLine();
      } catch (Throwable xx) {
      } finally {
      try {
      inputLines.close();
      } catch (Throwable xx) {}
      }
      label8.setValue("Done 5 " +line);
      } else if (text.startsWith("6")) {
      makeLogEntry("Button 6 pressed");
      String userInput = JOptionPane.showInputDialog(null, "Enter a string");
      label8.setValue("Done 6" +" User input: " +(userInput == null ? "{NULL}" : userInput));
      } else if (text.startsWith("7")) {
      makeLogEntry("Button 7 pressed");
      label8.setValue("Done 7 - I don't do a thing.");
      } else {
      label8.setValue("Lable sans Number");
      }
            } catch (Throwable xx) {
      try {
      ByteArrayOutputStream baoStream = new ByteArrayOutputStream(2000);
      PrintStream stringStream = new PrintStream(baoStream);
      xx.printStackTrace(stringStream); //A PrintStream
      JOptionPane.showMessageDialog(null, baoStream.toString());
      } catch (Throwable yy) {
      label8.setValue(yy.getMessage() == null ? "ERROR" : yy.getMessage());
      }
            }
          }
        }

      }

      ---- Manifest: ----
      Manifest-Version: 1.0
      Created-By: Garr Lystad
      Main-Class: com.worksoft.security.SecurityApplet
      Application-Name: Manifest Destiny Garr's Security Applet
      Permissions: all-permissions
      Application-Library-Allowable-Codebase: *
      Caller-Allowable-Codebase: *
      Codebase: *

      ---- section of deployment.properties file: ----
      deployment.javaws.jre.0.args=-agentlib:jdwp\=transport\=dt_socket,server\=y,suspend\=y,address\=10471
      deployment.javaws.jre.0.path=C\:\\Program Files (x86)\\Java\\jre1.8.0_66\\bin\\javaw.exe
      deployment.javaws.jre.0.product=1.8.0_66
      deployment.javaws.jre.0.osarch=x86
      deployment.javaws.jre.0.registered=true
      deployment.javaws.jre.0.location=http\://java.sun.com/products/autodl/j2se
      deployment.javaws.jre.0.platform=1.8
      deployment.javaws.jre.0.osname=Windows
      deployment.javaws.jre.0.enabled=true

      ---- NOTE: ----
      If you need anything else please let me know.


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

      CUSTOMER SUBMITTED WORKAROUND :
      I don't know of any other than not using any breakpoints and a debugger's not much good without them.

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: