{"record":{"id":"3e48fe1055318f5e","repo":"stanfordnlp/CoreNLP","slug":"node-right-parent-is-not-same-as-node","errorCode":null,"errorMessage":"node right parent is not same as node!!!","messagePattern":"node right parent is not same as node!!!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/IntervalTree.java","lineNumber":390,"sourceCode":"        maxEnd = leftMax;\n      }\n      if (rightMax != null && rightMax.compareTo(maxEnd) > 0) {\n        maxEnd = rightMax;\n      }\n      if (!maxEnd.equals(node.maxEnd)) {\n        throw new IllegalStateException(\"max end is not as expected!!!\");\n      }\n      if (node.size != leftSize + rightSize + 1) {\n        throw new IllegalStateException(\"node size is not one plus the sum of left and right!!!\");\n      }\n      if (node.left != null) {\n        if (node.left.parent != node) {\n          throw new IllegalStateException(\"node left parent is not same as node!!!\");\n        }\n      }\n      if (node.right != null) {\n        if (node.right.parent != node) {\n          throw new IllegalStateException(\"node right parent is not same as node!!!\");\n        }\n      }\n      if (node.parent != null) {\n        // Go up parent and make sure we are on correct side\n        TreeNode<E,T> n = node;\n        while (n != null && n.parent != null) {\n          // Check we are either right or left\n          if (n == n.parent.left) {\n            // Check that node is less than the parent\n            if (node.value != null) {\n              if (node.value.getInterval().compareTo(n.parent.value.getInterval()) > 0) {\n                throw new IllegalStateException(\"node is not on the correct side!!!\");\n              }\n            }\n          } else if (n == n.parent.right) {\n            // Check that node is greater than the parent\n            if (node.value.getInterval().compareTo(n.parent.value.getInterval()) <= 0) {\n              throw new IllegalStateException(\"node is not on the correct side!!!\");","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/IntervalTree.java#L372-L408","documentation":"check() verifies parent/child linkage consistency: a node's right child must have its parent pointer set back to that node. This IllegalStateException fires when node.right != null but node.right.parent != node, meaning the tree's bidirectional links are out of sync. Like its left-child counterpart, it signals internal structural corruption from a failed update or rotation.","triggerScenarios":"check() (or balance()/rotateUp() that call it) visits a node whose right child's parent field references a different node (or null) — typically after rotateUp or remove updated one side of the link but not the other.","commonSituations":"Encountered debugging CoreNLP interval-tree removals or rebalances; after unsynchronized concurrent access; after subclass or reflection code altered node fields.","solutions":["Rebuild the IntervalTree and re-insert all intervals to restore consistent links.","Restrict all mutations to the public API; do not touch TreeNode internals.","Add external locking or single-thread the tree's use to avoid interleaved structural updates.","Minimize the reproducing operation sequence and report upstream if public API alone triggers it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try {\n  tree.check(tree.root);\n} catch (IllegalStateException e) {\n  // right-child parent link broken -> rebuild\n}","typeGuard":null,"tryCatchPattern":"try {\n  tree.check(tree.root);\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"right parent\")) { tree = rebuildTree(intervals); }\n}","preventionTips":["Treat TreeNode internals as opaque; the public API maintains all links.","Avoid interleaving insert and remove from multiple threads.","Rebuild rather than patching corrupted structures.","Run structural checks in CI tests after randomized operation sequences."],"tags":["interval-tree","invariant","parent-pointer","corenlp"],"backgroundTag":"internal-invariant-violation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}