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: index out of bounds #29

Open
intendednull opened this issue Aug 20, 2021 · 3 comments
Open

Panic: index out of bounds #29

intendednull opened this issue Aug 20, 2021 · 3 comments

Comments

@intendednull
Copy link

My app generates polygons many times a second. Sometimes it panics with the following:

index-c3cba34161ffd897.js:406 panicked at 'index out of bounds: the len is 1 but the index is 4294967295', /home/user/.cargo/git/checkouts/rust-geo-booleanop-3fbb75e5fa6cd1f8/188f016/lib/src/boolean/connect_edges.rs:180:38

It only seems to happen when taking the difference. Below are some vertices that have caused the issue:

p1 = [(-87.89134, 223.90228), (-93.1746, -213.39839), (-99.17416, -213.32591), (-93.8909,  223.97476)]
p2 = [(-30.8955, 223.21368), (-33.432434, 13.228989), (-153.42368, -14.678665), (-150.88675, 224.66336)]
@michaelkirk
Copy link
Contributor

the index is 4294967295

In case you missed it, 4294967295 == 2**32 - 1, so, I'm suspicious of some kind of overflow.

Are you working with huge numbers of geometries?

Also I noticed from your error message:

index-c3cba34161ffd897.js:406

So, am I correct that you're targeting wasm?

Do you have any reproducible script that can induce this panic?

@AlanRace
Copy link

AlanRace commented May 27, 2022

I have also encountered this issue. It seems that the problem occurs when get_output_contour_id() returns -1 as this (i32) is then converted to a usize and causes this problem.

let lower_contour_id = prev_in_result.get_output_contour_id();
if prev_in_result.get_result_transition() == ResultTransition::OutIn {
// We are inside. Now we have to check if the thing below us is another hole or
// an exterior contour.
let lower_contour = &contours[lower_contour_id as usize];

It seems that output_contour_id is initialised to -1 and so I guess this is never updated before it is accessed? Do you know why that would be?

@bluenote10
Copy link
Contributor

Just a guess, but I think it may all come down to the discussion over here: #17 (comment)

Mutating the search tree in a way that violates the search tree invariant can sooner or later lead to a bug. I assume this is just another (later) manifestation of the problem.

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

4 participants