fix(core): skip non-hole remnants in OGC extraction#78
Closed
Filyus wants to merge 1 commit into
Closed
Conversation
Member
|
Thank you for your time and research. This now looks like a real problem. Let me look into it, and I'll give you my feedback. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Member
Author
|
You're welcome! I'll update the PR or create a new one today. |
Author
|
Closing this implementation PR in favor of a separate test-only PR as requested. The minimized regression case is now in #79 without a proposed solution. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
extract_ogccan panic on a self-touching / near-degenerate subject shape when using OGC output.A minimized standalone reproducer is available here:
https://github.com/Filyus/ioverlay-repro
With
i_overlay = 7.0.0:The release panic is a downstream symptom. The debug assertion shows the earlier invariant break.
Root Cause
The first OGC pass classifies contours and skips hole contours for a second pass. In a self-touching sliver case,
skip_contourcan mark a larger traversal asHoleVisited. That traversal may include non-hole remnants whose fill does not satisfy:During the second hole pass, the actual hole contour is extracted first. Some non-hole remnants can remain unvisited in the hole-only buffer. The second pass then tries to treat those remnants as hole starts.
In debug this hits:
In release the invalid pseudo-hole can reach
join_sorted_holes, where parent lookup returnsContourIndex::EMPTY;EMPTY.index()becomesusize::MAX >> 1, producing the9223372036854775807panic.Fix
When the second OGC pass encounters a
HoleVisitedremnant whosefillis not valid for the currentoverlay_rule, consume that contour and continue instead of adding it toholes/anchors.This keeps the invariant local to OGC extraction:
Only contours that actually satisfy the hole-start condition are passed to hole binding.
This is intentionally not a
ShapeBinderfallback: the binder was receiving invalid pseudo-hole input. The fix is applied at the earlier stage where that input is produced.Regression Test
Adds a minimized 4-contour / 13-point float regression case derived from the standalone repro. The test uses:
OverlayRule::SubjectFillRule::NonZero50000clean_result = trueogc = truepreserve_output_collinear = trueVerification
The standalone repro also passes when patched to this local branch:
Supersedes
This supersedes #77. That PR handled the downstream
ContourIndex::EMPTYpanic inShapeBinder; this PR fixes the earlier OGC extraction invariant violation that produces the invalid pseudo-hole.Note
Prepared with LLM assistance and validated with a minimized standalone reproducer plus debug/release test suites.