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

unexpected seg fault during union #736

Closed
jandrejevic12 opened this issue Nov 30, 2023 · 2 comments
Closed

unexpected seg fault during union #736

jandrejevic12 opened this issue Nov 30, 2023 · 2 comments

Comments

@jandrejevic12
Copy link

Hello,

I was testing a union in the following small C++ example when I encountered an unexpected seg fault:

seg_fault_example
Paths64 subject;
subject.push_back(MakePath({3333339, -61588000, 31148604, -61588000, -2296358, -43414476, -922323, -72134223}));
subject.push_back(MakePath({750923, -61588000, 28566188, -61588000, -4878774, -43414476, -3504739, -72134223}));
subject.push_back(MakePath({28720589, -50574319, 28566188, -61588000, 31148604, -61588000}));
Paths64 result = Union(subject, FillRule::NonZero);

There are a few exactly touching vertices among the polygons, and perturbing them does resolve the issue. I tried to pinpoint the precise location of the seg fault, and the issue arises inside ClipperBase::Split line 2746 (e.next_in_ael->join_with = JoinWith::None;) where e.next_in_ael evaluates to nullptr thus producing the seg fault. Do you have any thoughts on why this might be the case? Thanks for your help!

@AngusJohnson
Copy link
Owner

Replace:

if (IsOpen(e) || !IsHotEdge(e) || !prev ||
IsOpen(*prev) || !IsHotEdge(*prev)) return;

if (IsOpen(e) || !IsHotEdge(e) ||
!next || IsOpen(*next) || !IsHotEdge(*next)) return;

with:

    if ( IsOpen(e) || !IsHotEdge(e) || !prev || IsHorizontal(e) ||
      IsOpen(*prev) || !IsHotEdge(*prev) || IsHorizontal(*prev) ) return;
    if ( IsOpen(e) || !IsHotEdge(e) || IsHorizontal(e) ||
      !next || IsOpen(*next) || !IsHotEdge(*next) || IsHorizontal(*next) ) return;

@jandrejevic12
Copy link
Author

Thank you so much, that fixed the issue! :)

AngusJohnson added a commit that referenced this issue Dec 1, 2023
Fixed bugs in PointInPolygon benchmark testing.
@yoavmil yoavmil mentioned this issue Dec 5, 2023
jiajuncccc added a commit to jiajuncccc/Clipper2 that referenced this issue Dec 15, 2023
* remotes/origin/main:
  Minor code tidy
  Added CLIPPER2_HI_PRECISION option in CMakeLists.txt
  Additional minor tweaks to cpp/benchmark tests
  Make googletest not be a git submodule, and instead clone it separately in the CI script (AngusJohnson#745)
  fix compiler warning of -Wunused-but-set-parameter with -fno-exceptions (AngusJohnson#744)
  Additional tweaks to GetIntersectPtBenchmark.cpp
  Additional GetIntersectPtBenchmark tweaks
  Fixed incorrect code comment
  Added new GetIntersectPoint benchmark test Updated other benchmark tests.
  Code formatting only (removed trailing spaces)
  Fixed minor typecasting issues (AngusJohnson#727)
  More tweaks to PointInPolygon benchmarking.
  Allow using external gtest with GTest:: qualified names (AngusJohnson#737)
  Fixed a significant (though uncommon) bug in polygon clipping (AngusJohnson#736) Fixed bugs in PointInPolygon benchmark testing.
  Minor tweaks to PointInPolygon benchmark testing.
  Fixed a minor syntax error tripping some C++ compilers
  Version 1.3.0 1. Fixed a significant offsetting bug introduced in previous update (AngusJohnson#733) 2. Fixed a C++ compile error when 32bit compiling (AngusJohnson#727) 3. Minor tweak to CMakeLists.txt (C++) (AngusJohnson#728) 4. Will now offset 'flat' polygons (Disc.AngusJohnson#725) 5. Reminder: recent change in open path offsetting behaviour (AngusJohnson#707) 6. Reminder: recent changes to clipper.export.h data structures.
  Fixed a typo and tweaked documentation
  Version 1.2.4   Changes since ver 1.2.3 include:   1. Important: Offsetting open path behaviour has changed.      The delta now behaves as it did in Clipper1 (See Issue AngusJohnson#707)   2. Important: Data structures of exported values in clipper.export.h have changed.   3. Minor bugfixes to PolyTree nesting (AngusJohnson#679, AngusJohnson#687)   4. Numerous minor bugfixes to polygon offsetting (AngusJohnson#703, AngusJohnson#715, AngusJohnson#724)   5. Fixed an obscure bug in polygon clipping caused by horizontal spikes (AngusJohnson#720)   6. Significantly improved documentation.
  Additional minor bugfix to ClipperOffset (AngusJohnson#724 & Disc.AngusJohnson#726)
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

2 participants