geo icon indicating copy to clipboard operation
geo copied to clipboard

Panic in RegionAssembly reproducibly

Open frehberg opened this issue 2 years ago • 4 comments

Occasionally (1:8) I observe a panic condition. I managed to print out the data of RegionAssembly causing the panic, and using this data to create a regression test (see PR)

Code with regresssion test assembling 3668 segments/lines https://github.com/georust/geo/pull/1126

The panic occures in the the check in file assembly.rs

            debug_assert!(num_segments % 2 == 0, "assembly segments must be eulierian");

The execution path leading to this point of the RegionAssembly occures in the context of bop.sweep() in the following code

impl<T: GeoFloat> BooleanOps for MultiPolygon<T> {
    type Scalar = T;

    fn boolean_op(&self, other: &Self, op: OpType) -> MultiPolygon<Self::Scalar> {
        let spec = BoolOp::from(op);
        let mut bop = Proc::new(spec, self.coords_count() + other.coords_count());
        bop.add_multi_polygon(self, 0);
        bop.add_multi_polygon(other, 1);
        bop.sweep()
    }

Appreciating any hint why this crash occures and how to avoid the panic crash

Screenshot from 2023-12-21 11-30-58

frehberg avatar Dec 21 '23 10:12 frehberg

#1102, #1103, and #1104 may be related here.

urschrei avatar Dec 21 '23 13:12 urschrei

is the code of RegionAssembly crashing due to a bug in the algorithm, or due to bad input parameters? In case of the latter, how to prevent this?

frehberg avatar Jan 08 '24 09:01 frehberg

It's crashing due to a bug, and a fix is unlikely in the short term.

urschrei avatar Jan 08 '24 11:01 urschrei

hopefully this test https://github.com/georust/geo/pull/1126 can help you to reproduce the issue and fix the code

frehberg avatar Jan 09 '24 09:01 frehberg

I believe this is a dupe of https://github.com/georust/geo/issues/913

That issue is still open - but let's try to focus any future discussion on this bug there. Note there may be other bugs with the boolean operations - this one in particular is about the "assembly segments must be eulierian", which I believe is caused by a collapse of floating point precision.

Feel free to re-open if I'm mistaken and this represents a different bug.

michaelkirk avatar Jul 30 '24 22:07 michaelkirk