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

Integer overflow when creating meshed 3D cylinders

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx21, jfx24
    • javafx
    • None
    • generic
    • generic

      When creating 3D cylinders via the three-parameter constructor, the last value defines a custom mesh granularity.

            int meshdiv = Integer.MAX_VALUE / div ;
            Cylinder cylinder = new Cylinder(10,10,meshdiv);

      During the subsequent mesh creation is no further check whether this value can cause overflows or oversized allocations.

      Hence we can observe:

      a) div = 1
      Exception in thread "JavaFX Application Thread" java.lang.NegativeArraySizeException: -24
      at javafx.graphics@25-metal/javafx.scene.shape.Cylinder.createMesh(Cylinder.java:416)
      ...
      or

      b) div = 64
      Exception in thread "JavaFX Application Thread" java.lang.OutOfMemoryError: Java heap space
      at java.base/java.util.Arrays.copyOf(Arrays.java:3591)
      at javafx.base@25-metal/com.sun.javafx.collections.ObservableIntegerArrayImpl.ensureCapacity(ObservableIntegerArrayImpl.java:254)
           ...

        1. CylinderBug.java
          1.0 kB
          Marc Schönefeld
        2. SphereBug.java
          1 kB
          Marc Schönefeld

            jdv Jayathirth D V
            mschoene Marc Schönefeld
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: