java3d
  1. java3d
  2. JAVA3D-584

Calling ImageComponent2D.set(NIOImageBuffer) with the wrong number of components will hang system

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.5.2
    • Fix Version/s: 1.6.0
    • Component/s: j3d-core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      584

      Description

      Calling ImageComponent2D.set(NIOImageBuffer) with the wrong number of components
      will hang the system if the ImageComponent2D is live.

      For example, attempting to set a 3-component image in an image component with 4
      components will cause the following exception to be throw, as expected:

      java.lang.IllegalArgumentException: ImageComponent: Mismatch in the number of
      components between format and image buffer.
      at
      javax.media.j3d.ImageComponentRetained.isImageTypeSupported(ImageComponentRetained.java:651)
      at
      javax.media.j3d.ImageComponent2DRetained.set(ImageComponent2DRetained.java:85)
      at javax.media.j3d.ImageComponent2D.set(ImageComponent2D.java:409)
      at
      org.jdesktop.lg3d.wonderland.scenemanager.AssetManager$NodeUpdater$1.updateData(AssetManager.java:1447)
      at
      javax.media.j3d.ImageComponent2DRetained.updateData(ImageComponent2DRetained.java:282)
      at javax.media.j3d.ImageComponent2D.updateData(ImageComponent2D.java:641)
      at
      org.jdesktop.lg3d.wonderland.scenemanager.AssetManager$NodeUpdater.processStimulus(AssetManager.java:1445)
      at javax.media.j3d.BehaviorScheduler.doWork(BehaviorScheduler.java:192)
      at javax.media.j3d.J3dThread.run(J3dThread.java:275)

      The problem is that when the above exception is thrown, the image is left locked
      by the calling thread, which causes the MasterControl thread to hang while
      trying to acquire the lock. This in turn hangs the entire system with no way to
      recover.

      Since a user error is needed to trigger this bug, the simple workaround is
      "don't do that".

        Activity

        Hide
        kcr added a comment -

        Set target milestone to post-1.5.2 release.

        Evaluation:

        A quick, partial fix is to ensure that the code within lock()/unlock() pairs is
        in a try/finally block, so that the unlock will always happen even if an
        exception occurs (a good idea in any case). A more complete fix would also
        ensure that nothing else in the object is left in an internally inconsistent
        state. Any method that can throw an IllegalArgumentException or other similar
        exception in response to user input should leave the object in the same state it
        was in before the method was called if the exception is thrown. This means that
        all error check should be done before setting any field in the object, or else
        there needs to be a way to restore the state in a "finally" block.

        Show
        kcr added a comment - Set target milestone to post-1.5.2 release. Evaluation: A quick, partial fix is to ensure that the code within lock()/unlock() pairs is in a try/finally block, so that the unlock will always happen even if an exception occurs (a good idea in any case). A more complete fix would also ensure that nothing else in the object is left in an internally inconsistent state. Any method that can throw an IllegalArgumentException or other similar exception in response to user input should leave the object in the same state it was in before the method was called if the exception is thrown. This means that all error check should be done before setting any field in the object, or else there needs to be a way to restore the state in a "finally" block.

          People

          • Assignee:
            java3d-issues
            Reporter:
            kcr
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: