stanfordnlp/CoreNLP · error · IllegalStateException
node is same as parent!!!
Error message
node is same as parent!!!
What it means
IntervalTree.adjustUpwards walks up the tree updating maxEnd and size aggregates. If it reaches a node whose parent pointer points at itself, the tree's structure invariant is broken, and it throws IllegalStateException 'node is same as parent!!!' to prevent an infinite loop.
Solutions
- Report/fix the tree manipulation code; do not share the IntervalTree across threads without synchronization
- Rebuild the IntervalTree from the data set instead of relying on the corrupted instance
- Avoid directly mutating TreeNode parent/child links; use only public add/remove APIs
Defensive patterns
Strategy: try-catch
Try / catch
try { tree.remove(x); } catch (IllegalStateException e) { tree = new IntervalTree<>(recoveredItems); } Prevention
- Never mutate IntervalTree from multiple threads without external synchronization
- Do not manipulate internal TreeNode links directly
- Rebuild the tree if any IllegalStateException is observed; the structure is corrupt
When it happens
Trigger: An internal invariant violation while rebalancing after remove/adjust operations — a node's parent reference equals itself, typically caused by a bug in tree surgery or by concurrent modification of the tree.
Common situations: Corrupted IntervalTree state after a partially failed remove; custom subclasses manipulating TreeNode links directly; unsynchronized concurrent inserts/removes.
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
- Empty node shouldn't have left branch
- Empty node shouldn't have right branch
- max end is not as expected!!!
- node is not on the correct side!!!
- node is not parent's left or right child!!!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/9cf62b930bd81c94.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/IntervalTree.java:339
adjustUpwards(node, null);
}
// Adjust upwards starting at this node until stopAt
private void adjustUpwards(TreeNode<E,T> node, TreeNode<E,T> stopAt) {
TreeNode<E,T> n = node;
while (n != null && n != stopAt) {
int leftSize = (n.left != null)? n.left.size:0;
int rightSize = (n.right != null)? n.right.size:0;
n.maxEnd = n.value.getInterval().getEnd();
if (n.left != null) {
n.maxEnd = Interval.max(n.maxEnd, n.left.maxEnd);
}
if (n.right != null) {
n.maxEnd = Interval.max(n.maxEnd, n.right.maxEnd);
}
n.size = leftSize + 1 + rightSize;
if (n == n.parent) {
throw new IllegalStateException("node is same as parent!!!");
}
n = n.parent;
}
}
private void adjust(TreeNode<E,T> node) {
adjustUpwards(node, node.parent);
}
public void check() {
check(root);
}
public void check(TreeNode<E,T> treeNode) {
Stack<TreeNode<E,T>> todo = new Stack<>();
todo.add(treeNode);
while (!todo.isEmpty()) {
TreeNode<E,T> node = todo.pop();View on GitHub (pinned to 1b7edd19c4)