Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic after inserting Rectangle with NaN to RTree #112

Open
jakoschiko opened this issue Feb 18, 2023 · 0 comments
Open

Panic after inserting Rectangle with NaN to RTree #112

jakoschiko opened this issue Feb 18, 2023 · 0 comments

Comments

@jakoschiko
Copy link

I wrote a program that generates random shapes and inserts them into a RTree. I accidentally generated some shapes that contained NaN and to my surprise, the program panicked. The panic occurred inside rstar.

Here a minimal example that I've tested with rstar 0.10.0

use rstar::{RTree, primitives::Rectangle};

fn main() {
    let mut tree = RTree::new();
    tree.insert(Rectangle::from_corners([-1.4, 1.0], [-1.3, 1.1]));
    tree.insert(Rectangle::from_corners([2.3, 0.0], [2.4, 0.0]));
    tree.insert(Rectangle::from_corners([-1.4, -0.4], [-1.4, -0.2]));
    tree.insert(Rectangle::from_corners([f32::NAN, f32::NAN], [f32::NAN, f32::NAN]));
    tree.insert(Rectangle::from_corners([1.8, -1.8], [1.9, -1.8]));
    tree.insert(Rectangle::from_corners([0.2, -0.5], [0.3, -0.4]));
    tree.insert(Rectangle::from_corners([-0.6, -0.6], [-0.4, -0.5])); // This will panic!
}

Output:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/explorer/.cargo/registry/src/github.com-1ecc6299db9ec823/rstar-0.10.0/src/algorithm/rstar.rs:345:14

Rust explorer link

Is this intentional behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant