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

Area.intersect throws OOM or never ends

XMLWordPrintable

    • 2d
    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10, jdk 13.0.1, also jdk8 202

      A DESCRIPTION OF THE PROBLEM :
      The attached code either never ends or throws OOM. The code is reduced from https://issues.apache.org/jira/browse/PDFBOX-4718 :
      - download PDFDebugger
        https://pdfbox.apache.org/download.cgi
        search for debugger-app-2.0.18.jar
      - run it
      - press CTRL-U for "open URL" dialog
      - enter
        https://issues.apache.org/jira/secure/attachment/12989118/example.pdf

      never ends or throws OOM

      possibly duplicate of JDK-6955969, but that one has no sample code, and does end after some time.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the attached code
      "C:\Program Files\Java\jdk-13.0.1\bin\java" -Xmx2g -jar PDFBox4718Intersect.jar

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      alive1
      alive2
      alive3
      ACTUAL -
      alive1
      alive2
      Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
              at java.desktop/sun.awt.geom.AreaOp.resolveLinks(AreaOp.java:454)
              at java.desktop/sun.awt.geom.AreaOp.pruneEdges(AreaOp.java:393)
              at java.desktop/sun.awt.geom.AreaOp.calculate(AreaOp.java:159)
              at java.desktop/java.awt.geom.Area.intersect(Area.java:293)
              at pdfbox4718intersect.PDFBox4718Intersect.main(PDFBox4718Intersect.java:32)

      ---------- BEGIN SOURCE ----------
      package pdfbox4718intersect;

      import java.awt.geom.Area;
      import java.awt.geom.GeneralPath;
      import java.awt.geom.Rectangle2D;

      public class PDFBox4718Intersect
      {

          public static void main(String[] args)
          {
              Area clip = new Area(new Rectangle2D.Double(0d, 0d, 567d, 828d));
              GeneralPath path = new GeneralPath();
              path.moveTo(0, 0);
              path.curveTo(0.82925d, 497.194d, 0.39322d, 497.402d, 0.027405d, 497.402d);
              path.curveTo(-0.16574d, 497.402d, -0.33868d, 497.345d, -0.46979d, 497.225d);
              path.lineTo(40.816d, 531.788d);
              clip.intersect(new Area(path));
              System.out.println("alive1");

              path = new GeneralPath();
              path.moveTo(-14.161d, 841.889d);
              path.lineTo(581.103d, 51.038d);
              path.lineTo(-14.161d, 51.038d);
              clip.intersect(new Area(path));
              System.out.println("alive2");

              path = new GeneralPath();
              path.moveTo(0, 0);
              path.curveTo(0.82925d, 497.194d, 0.39322d, 497.402d, 0.027405d, 497.402d);
              path.curveTo(-0.16574d, 497.402d, -0.33868d, 497.345d, -0.46979d, 497.225d);
              clip.intersect(new Area(path));
              System.out.println("alive3");
          }
      }

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

      FREQUENCY : always


            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: