fix(#263): carry OCCT kernel patch — ShapeFix_Face non-face context replacement#265
Merged
Conversation
… replacement Root-caused the upstream OCCT crash behind #263 (Open-Cascade-SAS/OCCT#1322): ShapeFix_Face::Perform casts `Context()->Apply(myFace)` to TopoDS_Face without a type check. When an earlier fix in the shared ReShape context has replaced the face with a COMPOUND (a self-intersecting face split into several faces), Apply() returns a non-face; the unchecked cast builds an invalid face handle over a compound TShape and corrupts the heap — aborting with an uncatchable OS signal (FixOrientation → BRep_Tool::Curve → BRep_TEdge::EmptyCopy, SIGSEGV/SIGBUS at varying addresses). Found by linking a debug-built ShapeFix_Face.cxx over the prebuilt lib: at -O0 the bad cast throws Standard_TypeMismatch at ShapeFix_Face.cxx:383 with S.type=COMPOUND while myFace.type=FACE. Patch guards the cast (return early when S is not a face — the replacement is already in the context). Validated via single-TU override-link at -O2: the bowtie reproducer and all four crash-repro fixtures survive; ShapeFix output on valid box/sphere/cylinder is byte-identical to stock. Takes effect on the next xcframework rebuild; until then v1.8.3's in-wrapper occtHasSelfIntersectingWire guard prevents the crash from reaching this code. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ShapeFix_Face::Perform casts Context()->Apply(myFace) to TopoDS_Face in three places (the FixWire block, the per-subface loop, and the NeedCheckSplitWire block), all unguarded. The compound replacement already exists on entry to Perform (recorded by a prior face's fix), so a single guard at the top — return early when Apply(myFace) is not a face — covers all three. Cleaner than the per-site guard and the bowtie prism now heals to a valid 8-face solid (was: returned the compound unchanged). Validated via -O2 override-link; box/sphere ShapeFix output unchanged. Matches the upstream PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Upstream fix submitted: Open-Cascade-SAS/OCCT#1323 (same top-of-Perform guard + a GTest regression case). When that merges and ships in an OCCT release, this carried patch can be dropped. |
Rebuilds the xcframework from occt-src V8_0_0_p1 + the carried ShapeFix_Face guard (Scripts/patches/0001). Bumps the binaryTarget URL to v1.8.4 and the checksum to the new zip. Full suite green against the new binary (the only non-passes are the known flaky cone STEP round-trip and a construction-layer count test — both pass in isolation and are unaffected by the guard, which only triggers on a non-face context replacement). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Draft — carries the upstream OCCT kernel fix for #263. Takes effect only on the next xcframework rebuild; the in-wrapper guard shipped in v1.8.3 (#264) protects consumers until then.
Root cause (upstream OCCT — Open-Cascade-SAS/OCCT#1322)
ShapeFix_Face::Perform(ShapeFix_Face.cxx:382-383) does:When an earlier fix sharing the same
ShapeBuild_ReShapecontext has replaced the face with a compound (a self-intersecting face split into several faces),Apply()returns a non-face.TopoDS::Faceover a compoundTShapebuilds an invalid face handle → heap corruption → uncatchable OS signal downstream (FixOrientation→BRep_Tool::Curve→BRep_TEdge::EmptyCopy, SIGSEGV/SIGBUS at varying addresses — the exact #263 backtrace).Pinned by linking a debug-built
ShapeFix_Face.cxxover the prebuilt lib: at-O0the cast throwsStandard_TypeMismatchat line 383 withS.type=COMPOUND,myFace.type=FACE(on the 6th of 6 prism faces; the first 5 fix cleanly).Fix
Guard the cast — if
Sis not aTopAbs_FACE, record it as the result and return (the replacement is already in the context; nothing to fix here). One carried patch:Scripts/patches/0001-ShapeFix_Face-guard-non-face-context-replacement-263.patch.Validation (single-TU override-link at -O2, no full rebuild)
OCCTReconstructcrash-reprofixtures (b1214/b693/b135/b106): survive.ShapeFix_Shapeoutput on valid box/sphere/cylinder is byte-identical to stock (the guard only triggers for a non-face replacement, which never happens for a well-formed face).Next steps
OCCT.xcframeworkwith the patch (Scripts/build-occt.sh), attach the.zipasset, bumpPackage.swiftURL+checksum — then the in-wrapper guard becomes belt-and-suspenders.🤖 Generated with Claude Code