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

Infinite recursion with i_overlay 1.8 #1270

Closed
petersohn opened this issue Nov 15, 2024 · 2 comments · Fixed by #1275
Closed

Infinite recursion with i_overlay 1.8 #1270

petersohn opened this issue Nov 15, 2024 · 2 comments · Fixed by #1275

Comments

@petersohn
Copy link

I had the previous issue #1174, which was fixed in 0.29 by switching to i_overlay. It worked at first with i_overlay 1.7.2. However, after upgrading to i_overlay 1.7.2, I get a an infinite recursion whenever I try to find an intersection between a polygon and a line.

The input is the same as in #1174:

use geo::{BooleanOps, MultiLineString, MultiPolygon};

fn main() {
    let p: MultiPolygon = serde_json::from_str(
        r###"
[
    {
      "exterior": [
        {
          "x": 6.6322207,
          "y": 45.3989067
        },
        {
          "x": 6.6321662,
          "y": 45.3985289
        },
        {
          "x": 6.632198,
          "y": 45.3980443
        },
        {
          "x": 6.6323042,
          "y": 45.3976988
        },
        {
          "x": 6.632397,
          "y": 45.3975054
        },
        {
          "x": 6.6317152,
          "y": 45.397207
        },
        {
          "x": 6.6314034,
          "y": 45.3969161
        },
        {
          "x": 6.6310307,
          "y": 45.3967459
        },
        {
          "x": 6.6309416,
          "y": 45.3970552
        },
        {
          "x": 6.6314229,
          "y": 45.3979076
        },
        {
          "x": 6.6318818,
          "y": 45.3988548
        },
        {
          "x": 6.6322207,
          "y": 45.3989067
        }
      ],
      "interiors": []
    },
    {
      "exterior": [
        {
          "x": 6.6323953,
          "y": 45.3987234
        },
        {
          "x": 6.6323378,
          "y": 45.3989153
        },
        {
          "x": 6.6322207,
          "y": 45.3989067
        },
        {
          "x": 6.6318818,
          "y": 45.3988548
        },
        {
          "x": 6.6322392,
          "y": 45.4001182
        },
        {
          "x": 6.6323193,
          "y": 45.4007802
        },
        {
          "x": 6.6322762,
          "y": 45.4015879
        },
        {
          "x": 6.6319272,
          "y": 45.4020968
        },
        {
          "x": 6.6323646,
          "y": 45.4024108
        },
        {
          "x": 6.6336433,
          "y": 45.40104
        },
        {
          "x": 6.6333669,
          "y": 45.4009995
        },
        {
          "x": 6.6330465,
          "y": 45.4008567
        },
        {
          "x": 6.6326829,
          "y": 45.4003462
        },
        {
          "x": 6.6324734,
          "y": 45.3997238
        },
        {
          "x": 6.6324281,
          "y": 45.3989607
        },
        {
          "x": 6.6324484,
          "y": 45.3988529
        },
        {
          "x": 6.6325764,
          "y": 45.3988146
        },
        {
          "x": 6.6323953,
          "y": 45.3987234
        }
      ],
      "interiors": []
    }
  ]
"###,
    )
    .unwrap();

    let l: MultiLineString = serde_json::from_str(
        r###"
[
    [
      {
        "x": 6.6315782,
        "y": 45.3978329
      },
      {
        "x": 6.6322564,
        "y": 45.3996708
      }
    ]
  ]
    "###,
    )
    .unwrap();

    let c = p.clip(&l, true);
    println!("{:?}", c);
}

Here is the stack trace created with GDB:

(this repeats until the program aborts).
#261836 0x0000555555572727 in geo::algorithm::bool_ops::i_overlay_integration::f64::{impl#5}::clip_string_lines (self=0x7fffffffcc48, clip_rule=...)
    at /home/petersohn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/geo-0.29.1/src/algorithm/bool_ops/i_overlay_integration.rs:150
#261837 0x0000555555572727 in geo::algorithm::bool_ops::i_overlay_integration::f64::{impl#5}::clip_string_lines (self=0x7fffffffcc48, clip_rule=...)
    at /home/petersohn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/geo-0.29.1/src/algorithm/bool_ops/i_overlay_integration.rs:150
#261838 0x00005555555731c8 in geo::algorithm::bool_ops::BooleanOps::clip<geo_types::geometry::multi_polygon::MultiPolygon<f64>> (self=0x7fffffffcd90, multi_line_string=0x7fffffffcdc8, invert=true)
    at /home/petersohn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/geo-0.29.1/src/algorithm/bool_ops/mod.rs:112
#261839 0x000055555556ceba in rusttest::main () at src/main.rs:160
@frewsxcv
Copy link
Member

This should be temporarily resolved in #1271, which was just published in geo version 0.29.2. Let's leave this issue open until we fix the recursion issue so we're not blocked on an i_overlay upgrade.

@frewsxcv
Copy link
Member

Tagging you @NailxSharipov in case it's helpful to see this. Looks like the latest 1.8.0 release broke our build, so we're pinning to 1.7.x until one of us can investigate further.

michaelkirk added a commit that referenced this issue Nov 26, 2024
i_overlay 1.8 introduced a new trait based approach which allows us to
remove some of our own trait juggling.

However, our old friend, the orphan trait rule, prevents this from
happening easily. For now, I'm creating wrapper structs in geo for this
algo.

i_overlay 1.8 also introduced a new method signature for doing bool_ops,
removing the old ones. This caused our trait juggling to infinitely
recurse: See #1270

Now that we're using the new methods, the problem is avoided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants