java3d
  1. java3d
  2. JAVA3D-575

false SceneGraphCycleException raised when Node.checkForCycle() is called from 2 threads

    Details

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

      Operating System: All
      Platform: All

    • Issuezilla Id:
      575

      Description

      Calling Node.checkForCycle from two threads at the same time will throw a
      SceneGraphCycleException. Even though there is not a cycle in the scenegraph.

      The bug lies in Node.checkForCycle():

      void checkForCycle() {
      if (visited)

      { throw new SceneGraphCycleException(J3dI18N.getString("Node15")); }

      visited = true;
      Node parent = getParent();
      if (parent != null)

      { parent.checkForCycle(); }

      visited = false;
      }

      The member variable "visited" is set when entering and cleared when exiting the
      method checkForCycle. If a second thread enters the method the flag will be set
      and the exception raised.

      This bug can be fixed by either synchronizing the method, or rewrite it to not
      use a member variable:

      synchronized void checkForCycle() {
      Vector visitedNodes = new Vector();
      Node parent = this;
      while (parent != null) {
      if (visitedNodes.contains(parent))

      { throw new SceneGraphCycleException(J3dI18N.getString("Node15")); }

      visitedNodes.add(parent);
      parent = parent.getParent();
      }
      }

      I'll post a test case that will try to reproduce the bug. Although it may not
      always work since because of the threading.

        Issue Links

          Activity

          Hide
          lamer77 added a comment -

          Created an attachment (id=351)
          Class that tries to reproduce the SceneGraphSycle exception

          Show
          lamer77 added a comment - Created an attachment (id=351) Class that tries to reproduce the SceneGraphSycle exception
          Hide
          kcr added a comment -

          Yes, this is a bug, similar to other MT bugs such as issue 192 and issue 193.
          Until these bugs are addressed, the safest thing to do is to not do concurrent
          operations to a node and any of its descendants.

          Set to post-1.5.2 and lower priority to P4.

          Show
          kcr added a comment - Yes, this is a bug, similar to other MT bugs such as issue 192 and issue 193. Until these bugs are addressed, the safest thing to do is to not do concurrent operations to a node and any of its descendants. Set to post-1.5.2 and lower priority to P4.

            People

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

              Dates

              • Created:
                Updated: