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

Drawing GeneralPath with Double.NaN crashes JVM if antialias is on

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • CPU:
      x86, sparc
    • OS:
      solaris_8, windows_2000

      Description



      Name: jl125535 Date: 12/10/2001


      java version "1.3.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
      Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

      (This report also applies to Solaris 8 with both 1.3.1 and 1.4 beta 3.)

      Just run the following code
      #######################

      import java.awt.*;
      import java.awt.image.*;
      import java.awt.geom.*;

      public class TestNaN
      {

        public TestNaN()
          {
          GeneralPath path = new GeneralPath();
          path.append(new Line2D.Double(0, 0, 20, 20), true);
          path.append(new Line2D.Double(20, 20, 20, Double.NaN), true);

          try
            {
            BufferedImage image = new BufferedImage(300,300,BufferedImage.TYPE_INT_RGB
      );
            Graphics2D g2 = image.createGraphics();

            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
      RenderingHints.VALUE_ANTIALIAS_ON);
            System.err.println("draw path");
            g2.draw(path);

            System.err.println("After draw");
            }
          catch (Exception e)
            {
            System.err.println("exception in test NaN");
            }
          }


        public static void main(String[] args)
          {
          TestNaN testNaN1 = new TestNaN();
          }
      }

      Output

      draw path

      An unexpected exception has been detected in native code outside the VM.
      Unexpected Signal : 11 occurred at PC=0xeb11b8b8
      Function name=Java_sun_dc_pr_PathStroker_finalize
      Library=/usr/local/jdk1.3.1_01/jre/lib/sparc/libdcpr.so

      Current Java thread:
              at sun.dc.pr.PathFiller.setOutputArea(Native Method)
              at sun.dc.pr.Rasterizer.setOutputArea(Rasterizer.java:635)
              at
      sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:77)
              at sun.java2d.pipe.DuctusShapeRenderer.draw(DuctusShapeRenderer.java:48)
              at sun.java2d.pipe.ValidatePipe.draw(ValidatePipe.java:110)
              at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:1599)
              at TestNaN.<init>(TestNaN.java:21)
              at TestNaN.main(TestNaN.java:34)

      Dynamic libraries:
      0x10000 /usr/local/jdk1.3/bin/../bin/sparc/native_threads/java
      0xef760000 /usr/lib/libthread.so.1
      0xef7a0000 /usr/lib/libdl.so.1
      0xef680000 /usr/lib/libc.so.1
      0xef740000 /usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1
      0xee880000 /usr/local/jdk1.3.1_01/jre/lib/sparc/client/libjvm.so
      0xef620000 /usr/lib/libCrun.so.1
      0xef600000 /usr/lib/libsocket.so.1
      0xef500000 /usr/lib/libnsl.so.1
      0xef5c0000 /usr/lib/libm.so.1
      0xef650000 /usr/lib/libw.so.1
      0xef4e0000 /usr/lib/libmp.so.2
      0xef4b0000 /usr/local/jdk1.3.1_01/jre/lib/sparc/native_threads/libhpi.so
      0xef480000 /usr/local/jdk1.3.1_01/jre/lib/sparc/libverify.so
      0xef440000 /usr/local/jdk1.3.1_01/jre/lib/sparc/libjava.so
      0xeebd0000 /usr/local/jdk1.3.1_01/jre/lib/sparc/libzip.so
      0xed7a0000 /usr/local/jdk1.3.1_01/jre/lib/sparc/libawt.so
      0xeb180000 /usr/local/jdk1.3.1_01/jre/lib/sparc/motif12/libmawt.so
      0xed6b0000 /usr/local/jdk1.3/bin/../jre/lib/sparc/libmlib_image.so
      0xe4e00000 /usr/lib/libXm.so.3
      0xed590000 /usr/lib/libXt.so.4
      0xed4d0000 /usr/lib/libXext.so.0
      0xed690000 /usr/openwin/lib/libXtst.so.1
      0xeb080000 /usr/lib/libX11.so.4
      0xed4b0000 /usr/lib/libSM.so.6
      0xed480000 /usr/lib/libICE.so.6
      0xe3f00000 /usr/local/jdk1.3.1_01/jre/lib/sparc/libfontmanager.so
      0xeb020000 /usr/openwin/lib/libdps.so.5
      0xeb110000 /usr/local/jdk1.3.1_01/jre/lib/sparc/libdcpr.so

      Local Time = Thu Dec 6 16:05:06 2001
      Elapsed Time = 3
      #
      # The exception above was detected in native code outside the VM
      #
      # Java VM: Java HotSpot(TM) Client VM (1.3.1_01 mixed mode)
      #
      Segmentation Fault (core dumped)

      This happens only with antialiasing on.

      Now, I understand well enough that Double.NaN is a bad number. However, it's a
      valid Java primitive - meaning that it is recognized by the system as a valid
      double precision number and only additional efforts, i.e. Double.isNaN() can
      expose its invalidity. Accordingly Java2D API methods supposed to accept double
      arguments should have some reasonable way of dealing with it. The least they
      can do is to throw an Exception, even RuntimeException, even Error - something
      that alerts to a problem, but keeps the system alive. This is especially
      important for app servers - crashing the whole server because of some minor
      graphing problem seems to me a disaster. I would like to also point out that
      Windows JVM implementaion does not have this problem. There the system just
      ignores NaN - and assumes that the coordinate is 0. Not ideal, but much better.
      (Review ID: 137080)
      ======================================================================

      Name: rmT116609 Date: 01/04/2002


       DESCRIPTION OF THE PROBLEM :
      I found a test case where our program caused the jvm to crash. Testing on solaris with jdk 1.3 and 1.4 as well as windows 2000 jdk 1.3.0 1.3.1_02, jdk 1.4.0-beta3 demonstrated similar badness. Managed to narrow down the data to a few coordinates which will cause the crash.

       This crash only occurs when rendering to an offscreen (BufferedImage) image, and only when antialiasing is on. I have not been able to find other cases which cause this problem, but hopefully the 22 line application included here will help with the debugging effort.

      REGRESSION. Last worked in version 1.2.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile and run the attached program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expect it to exit cleanly.
      What it does is crap out and dump an error file (see error
      messages below).

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Graphics2D;
      import java.awt.RenderingHints;
      import java.awt.image.BufferedImage;
      import java.awt.geom.GeneralPath;

      public class Crash {
          public static void main(String args[]) {
              BufferedImage im = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB);
              Graphics2D g2d = im.createGraphics();
              g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

              GeneralPath path = new GeneralPath();

              path.moveTo(0.0f, 0.0f);
              path.lineTo(634.2308015993331f, 454.0807311500539f);
              path.lineTo(640.0f, 446.49493394504367f);

              path.closePath();

              g2d.draw(path);
          }
      }

      Error Message(with JDK1.4.0-beta3):

      C:\>java Crash

      An unexpected exception has been detected in native code outside the VM.
      Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D135C4C
      Function=[Unknown.]
      Library=C:\j2sdk1.4.0-beta3\jre\bin\dcpr.dll

      NOTE: We are unable to locate the function name symbol for the error
            just occurred. Please refer to release documentation for possible
            reason and solutions.


      Current Java thread:
              at sun.dc.pr.PathFiller.setOutputArea(Native Method)
              at sun.dc.pr.Rasterizer.setOutputArea(Rasterizer.java:635)
              at sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.ja
      va:79)
              at sun.java2d.pipe.DuctusShapeRenderer.draw(DuctusShapeRenderer.java:48)

              at sun.java2d.pipe.ValidatePipe.draw(ValidatePipe.java:117)
              at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:2165)
              at Crash.main(Crash.java:20)

      Dynamic libraries:
      0x00400000 - 0x00406000 c:\j2sdk1.4.0-beta3\bin\java.exe
      0x77F80000 - 0x77FFB000 C:\WINNT\System32\ntdll.dll
      0x77DB0000 - 0x77E0B000 C:\WINNT\system32\ADVAPI32.dll
      0x77E80000 - 0x77F35000 C:\WINNT\system32\KERNEL32.DLL
      0x77D40000 - 0x77DB0000 C:\WINNT\system32\RPCRT4.DLL
      0x78000000 - 0x78046000 C:\WINNT\system32\MSVCRT.dll
      0x6D330000 - 0x6D441000 c:\j2sdk1.4.0-beta3\jre\bin\client\jvm.dll
      0x77E10000 - 0x77E74000 C:\WINNT\system32\USER32.dll
      0x77F40000 - 0x77F7C000 C:\WINNT\system32\GDI32.DLL
      0x77570000 - 0x775A0000 C:\WINNT\System32\WINMM.dll
      0x6D1D0000 - 0x6D1D7000 c:\j2sdk1.4.0-beta3\jre\bin\hpi.dll
      0x6D300000 - 0x6D30D000 c:\j2sdk1.4.0-beta3\jre\bin\verify.dll
      0x6D210000 - 0x6D227000 c:\j2sdk1.4.0-beta3\jre\bin\java.dll
      0x6D320000 - 0x6D32D000 c:\j2sdk1.4.0-beta3\jre\bin\zip.dll
      0x6D000000 - 0x6D0F6000 C:\j2sdk1.4.0-beta3\jre\bin\awt.dll
      0x77800000 - 0x7781D000 C:\WINNT\System32\WINSPOOL.DRV
      0x75E60000 - 0x75E7A000 C:\WINNT\System32\IMM32.dll
      0x77A50000 - 0x77B46000 C:\WINNT\system32\ole32.dll
      0x6D180000 - 0x6D1D0000 C:\j2sdk1.4.0-beta3\jre\bin\fontmanager.dll
      0x6D130000 - 0x6D152000 C:\j2sdk1.4.0-beta3\jre\bin\dcpr.dll
      0x77920000 - 0x77943000 C:\WINNT\system32\imagehlp.dll
      0x72A00000 - 0x72A2D000 C:\WINNT\system32\DBGHELP.dll
      0x690A0000 - 0x690AB000 C:\WINNT\System32\PSAPI.DLL

      Local Time = Wed Jan 02 15:19:08 2002
      Elapsed Time = 0
      #
      # The exception above was detected in native code outside the VM
      #
      # Java VM: Java HotSpot(TM) Client VM (1.4.0-beta3-b84 mixed mode)
      #
      # An error report file has been saved as hs_err_pid1316.log.
      # Please refer to the file for further information.
      #

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

      CUSTOMER WORKAROUND :
      Turn off antialiasing...

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      ADDITIONAL OPERATING SYSTEMS :
      Solaris:
        uname -a gives:
        SunOS lsucal_05 5.8 Generic_108528-09 sun4u sparc
      SUNW,Sun-Fire-280R

      Possibly others...
      (Review ID: 137949)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              avu Alexey Ushakov
              Reporter:
              jleesunw Jon Lee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: