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

Rendering CubicCurve2D with NaN as control points causes crash in ductus code

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      beta
    • CPU:
      x86, sparc
    • OS:
      solaris_8, solaris_9, windows_xp

      Backports

        Description

        If some race condition causes the graphical view to try and paint when
        the data hasn't been filled in yet, JVM hangs or crashes. It seems which one it does depends on the AffineTransform being used at the time. A transform of
        [-1,-1] results in a crash; [1,1], a hang.

        The program below (CrashVM2.java) takes an argument of either "-crash" or "-hang":


        *****

        import java.awt.Color;
        import java.awt.Dimension;
        import java.awt.Graphics2D;
        import java.awt.Graphics;
        import java.awt.RenderingHints;
        import java.awt.geom.*;
        import java.awt.image.BufferedImage;
        import java.util.Date;
        import javax.swing.JFrame;
        import javax.swing.JPanel;

        public class CrashVM2 extends JPanel {

            CubicCurve2D.Double s1 = null;
            static boolean crash = false;

            public static void main(String[] args) {
                if (args.length != 1) {
                    usage();
                }
                if (args[0].equals("-crash")) {
                    crash = true;
                } else if (args[0].equals("-hang")) {
                    crash = false;
                } else {
                    usage();
                }
                JFrame f = new JFrame();
                f.getContentPane().add(new CrashVM2());
                f.setSize(640, 480);
                f.setVisible(true);
            }

            public static void usage() {
                System.out.println("Usage: CrashVM2 [-crash | -hang ]");
                System.exit(1);
            }
            
            
            public CrashVM2() {
                s1 = new CubicCurve2D.Double();
                s1.setCurve(1.0, 1.0,
                           Double.NaN, Double.NaN,
                           Double.NaN, Double.NaN,
                           0.0, 0.0);
            }
            
            public void paintComponent(Graphics g) {
                Graphics2D g2 = (Graphics2D) g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                     RenderingHints.VALUE_ANTIALIAS_ON);
                System.out.println("About to draw...");
                AffineTransform oldTransform = g2.getTransform();
                AffineTransform downRight = (AffineTransform) oldTransform.clone();
                AffineTransform upLeft = (AffineTransform) oldTransform.clone();
                downRight.translate(1.0,1.0);
                upLeft.translate(-1.0,-1.0);
                g2.setTransform(crash ? upLeft : downRight);
                g2.draw(s1);
                g2.setTransform(oldTransform);
                System.out.println("Done --> " + new Date().toString());
            }

        }

        ****************


          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  avu Alexey Ushakov
                  Reporter:
                  duke J. Duke (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: