Repository navigation
Fix overflow panic draining an empty tree with integer coordinates - #246
Merged
adamreichold merged 1 commit intoSep 11, 2026
Merged
Conversation
Member
|
This should not be necessary during every iteration step but only during iterator construction as the pathological AABB with only be forced upon the user by us for an empty tree as described in #184, in any other case the supplied coordinates were pathological to begin with. Also please don't post uselessly verbose LLM-generated PR descriptions. Everything that is meant to communicate with humans like us maintainers should be written by them. |
Contributor
Author
|
I'm sorry it's verbose, noted for this repo. |
michaelkirk
approved these changes
Sep 10, 2026
michaelkirk
left a comment
Member
There was a problem hiding this comment.
Fix LGTM, thanks!
I have a non-blocking concern about the documentation, but happy to merge either way.
`RTree::drain_within_distance` panicked with "attempt to multiply with overflow" whenever the tree was empty and the coordinate type was an integer, because the root of an empty tree carries `AABB::new_empty()`, whose lower corner is `Scalar::max_value()` and whose upper corner is `Scalar::min_value()`. The query side already guards against this in `SelectionIterator::new`, `SelectionIteratorMut::new`, `select_nodes` and `select_nodes_mut` by testing `!root.children.is_empty()` first, added in #184 to fix #161.
adamreichold
force-pushed
the
fix-drain-empty-tree-overflow
branch
from
September 11, 2026 09:34
86a1f34 to
c08c410
Compare
adamreichold
approved these changes
Sep 11, 2026
adamreichold
pushed a commit
that referenced
this pull request
Nov 1, 2026
) - [x] I agree to follow the project's [code of conduct](https://github.com/georust/.github/blob/main/CODE_OF_CONDUCT.md). - [x] I added an entry to the project's change log file if knowledge of this change could be valuable to users. --- `drain_within_distance` panicked with an arithmetic overflow on an empty tree with integer coordinates, because the removal function was handed the empty root envelope whose corners are the scalar type's maximum and minimum. The drain iterator now seeds its stack only when the root has children, matching the guard `SelectionIterator::new` already has. `test_drain_within_distance_on_empty_tree` covers a tree that was never filled and one emptied by removals, and it fails with the overflow if the guard is removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
drain_within_distancepanicked with an arithmetic overflow on an empty tree with integer coordinates, because the removal function was handed the empty root envelope whose corners are the scalar type's maximum and minimum. The drain iterator now seeds its stack only when the root has children, matching the guardSelectionIterator::newalready has.test_drain_within_distance_on_empty_treecovers a tree that was never filled and one emptied by removals, and it fails with the overflow if the guard is removed.