stanfordnlp/CoreNLP · error · IllegalStateException

node left parent is not same as node!!!

Error message

node left parent is not same as node!!!

What it means

check() verifies parent/child linkage consistency: a node's left child must have its parent pointer set back to that node. This IllegalStateException fires when node.left != null but node.left.parent != node, i.e. the doubly-linked structure is inconsistent. It indicates that insert/remove/rotation left a child whose parent pointer points elsewhere (or null), corrupting the tree.

Solutions

  1. Rebuild the tree from scratch and re-insert intervals — inconsistent pointers are not locally repairable safely.
  2. Use only the public insert/remove/overlap methods; never reassign node.left/right/parent in application code.
  3. Serialize access to the tree (it is not thread-safe) to prevent interleaved rotations from tearing links.
  4. If a minimal insert/remove sequence reproduces it, report to Stanford CoreNLP as a bug.
Defensive patterns

Strategy: try-catch

Validate before calling

try {
  tree.check(tree.root);
} catch (IllegalStateException e) {
  // parent/child link broken -> rebuild
}

Try / catch

try {
  intervalTree.insert(iv, v);
} catch (IllegalStateException e) {
  intervalTree = rebuildTree(allIntervals);
}

Prevention

When it happens

Trigger: check() (or balance()/rotateUp()) visits a node whose left child's parent field does not reference it — caused by a rotation or splice-out that updated child pointers without fixing the child's parent pointer.

Common situations: Seen while debugging tree surgery in CoreNLP (remove followed by check); after concurrent mutation of a shared IntervalTree; after external/deserialized manipulation of TreeNode fields.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/d00427c4d74094fb. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/util/IntervalTree.java:385

      int rightSize = (node.right != null)? node.right.size:0;
      E leftMax = (node.left != null)? node.left.maxEnd:null;
      E rightMax = (node.right != null)? node.right.maxEnd:null;
      E maxEnd = node.value.getInterval().getEnd();
      if (leftMax != null && leftMax.compareTo(maxEnd) > 0) {
        maxEnd = leftMax;
      }
      if (rightMax != null && rightMax.compareTo(maxEnd) > 0) {
        maxEnd = rightMax;
      }
      if (!maxEnd.equals(node.maxEnd)) {
        throw new IllegalStateException("max end is not as expected!!!");
      }
      if (node.size != leftSize + rightSize + 1) {
        throw new IllegalStateException("node size is not one plus the sum of left and right!!!");
      }
      if (node.left != null) {
        if (node.left.parent != node) {
          throw new IllegalStateException("node left parent is not same as node!!!");
        }
      }
      if (node.right != null) {
        if (node.right.parent != node) {
          throw new IllegalStateException("node right parent is not same as node!!!");
        }
      }
      if (node.parent != null) {
        // Go up parent and make sure we are on correct side
        TreeNode<E,T> n = node;
        while (n != null && n.parent != null) {
          // Check we are either right or left
          if (n == n.parent.left) {
            // Check that node is less than the parent
            if (node.value != null) {
              if (node.value.getInterval().compareTo(n.parent.value.getInterval()) > 0) {
                throw new IllegalStateException("node is not on the correct side!!!");
              }

View on GitHub (pinned to 1b7edd19c4)