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

Drawing very large coordinates with a dashed Stroke can cause Java to hang

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 17
    • 6u23, 8, 11, 15, 16, 17
    • client-libs
    • 2d
    • b05
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.6.0_23"
      Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
      Java HotSpot(TM) Client VM (build 19.0-b09, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7600]


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Windows 7 x64

      A DESCRIPTION OF THE PROBLEM :
      While testing a bug reported by one of our users, we were able to isolate a bug in DuctusShapeRenderer which causes 100% CPU

      Crashes Java.

      Two conditions need to be met:
      - Drawing with a BasicStroke (see example code)
      - Drawing large x/y values

      Here's a Thread dump I took while the error was happening:


      Thread [AWT-EventQueue-0] (Suspended)
      PathDasher.appendLine(float, float) line: not available [native method]
      Rasterizer.appendLine(float, float) line: 462
      DuctusRenderer.createShapeRasterizer(PathIterator, AffineTransform, BasicStroke, boolean, boolean, float) line: 495
      DuctusShapeRenderer.renderPath(SunGraphics2D, Shape, BasicStroke) line: 97
      DuctusShapeRenderer.draw(SunGraphics2D, Shape) line: 46
      PixelToParallelogramConverter.draw(SunGraphics2D, Shape) line: 130
      SunGraphics2D.draw(Shape) line: 2618
      ShapeDrawingUI.render(Graphics2D, ColorStyle) line: 103
      JC2DrawingUIFactory.createUIAndDrawLine(Drawing, Graphics2D, BasicStroke, ColorStyle, int, int, int, int, String) line: 99
      JC2DrawingUIFactory.drawLine(Graphics, int, int, int, int, ColorStyle, StrokeStyle, boolean, String, Drawing, Vector) line: 171
      Trendline.draw(DrawView, Graphics, int, Vector) line: 149
      SingleGraphRenderer.renderUserDrawings(Graphics, boolean, Vector) line: 710
      SingleGraphRenderer.render(Graphics2D) line: 655
      MultiGraphRenderer.render(Graphics2D) line: 255
      GraphManager.render(Graphics2D) line: 932
      GraphPanel.paintComponent(Graphics) line: 576
      GraphPanel(JComponent).paint(Graphics) line: 1029
      PContainer(JComponent).paintChildren(Graphics) line: 862
      PContainer(JComponent).paint(Graphics) line: 1038
      JPanel(JComponent).paintChildren(Graphics) line: 862
      JPanel(JComponent).paint(Graphics) line: 1038
      PSplitPane(JComponent).paintChildren(Graphics) line: 862
      PSplitPane(JSplitPane).paintChildren(Graphics) line: 1030
      PSplitPane(JComponent).paint(Graphics) line: 1038
      PContainer(JComponent).paintChildren(Graphics) line: 862
      PContainer(JComponent).paint(Graphics) line: 1038
      PContainer(JComponent)._paintImmediately(int, int, int, int) line: 5098
      PContainer(JComponent).paintImmediately(int, int, int, int) line: 4882
      RepaintManager.paintDirtyRegions(Map<Component,Rectangle>) line: 811
      RepaintManager.paintDirtyRegions() line: 713
      RepaintManager.seqPaintDirtyRegions() line: 693
      SystemEventQueueUtilities$ComponentWorkRequest.run() line: 125
      InvocationEvent.dispatch() line: 209
      EventQueue.dispatchEvent(AWTEvent) line: 633
      EventDispatchThread.pumpOneEventForFilters(int) line: 296
      EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 211
      EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 201
      EventDispatchThread.pumpEvents(int, Conditional) line: 196
      EventDispatchThread.pumpEvents(Conditional) line: 188
      EventDispatchThread.run() line: 122


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the attached code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No crash, rendering what's visible of the line
      ACTUAL -
      Java becomes unresponsive, hogs 100% CPU

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package net.prophet;

      import java.awt.BasicStroke;
      import java.awt.BorderLayout;
      import java.awt.Graphics;
      import java.awt.Graphics2D;
      import java.awt.Stroke;
      import java.awt.geom.Line2D;

      import javax.swing.JFrame;
      import javax.swing.JPanel;

      public class DrawingTest extends JPanel {

      public static void main(String[] args) {
      JFrame fr = new JFrame();
      fr.getContentPane().setLayout(new BorderLayout());
      DrawingTest drawingTest = new DrawingTest();
      fr.getContentPane().add(drawingTest, BorderLayout.CENTER);
      fr.setSize(400, 400);
      fr.setVisible(true);
      }

      @Override
      public void paintComponent(Graphics g) {
      Graphics2D g2 = (Graphics2D) g;
          
      // clip - doesn't help
      g2.setClip(0, 0, getWidth(), getHeight());

      // this part is just testing the drawing - so I can see I am actually drawing something
      // IGNORE
      /**
           g.setColor(Color.GREEN);
           g.fillRect(0, 0, getWidth(), getHeight());
           g.setColor(Color.black);
              g2.setStroke(new BasicStroke(2));
           g2.draw(new Line2D.Double(20, 20, 200, 20));
          
           /**/

      // Now we re-create the exact conditions that lead to the system crash in the JDK

      // BUG HERE - setting the stroke leads to the crash

           Stroke stroke = new BasicStroke(2.0f, 1, 0, 1.0f, new float[] {0.0f, 4.0f}, 0.0f);
           g2.setStroke(stroke);
          
           // NOTE: Large values to trigger crash / infinite loop?
           g2.draw(new Line2D.Double(4.0, 1.794369841E9, 567.0, -2.147483648E9));
          }



      }

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

            lbourges Laurent Bourgès
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: