Modeling Algorithms - Fix ChFi2d_Builder::AddChamfer null-edge dereference on a repeated pair - #1432
Open
gsdali wants to merge 1 commit into
Open
Conversation
This was referenced Aug 5, 2026
Merged
Merged
Member
|
Dear @gsdali please add GTest to cover your changes, you can follow the logic of all exited GTests. |
…rence on a repeated pair Description of the change: ChFi2d_Builder::AddChamfer(const TopoDS_Edge& E1, const TopoDS_Edge& E2, double D1, double D2) calls ChFi2d::FindConnectedEdges and dereferences the two edges it returns without checking the returned status first. FindConnectedEdges leaves both edges null on every failure path, and a second call naming the same edge pair hits exactly that: the pair's shared vertex is removed from the face's wire by the first call's own BuildNewWire, so the second call's lookup fails and the two null edges it returns reach ComputeChamfer unchecked. Adds the same status check the sibling overload, AddChamfer(const TopoDS_Edge& E, const TopoDS_Vertex& V, double D, double Ang), already has immediately after the identical FindConnectedEdges call. chamfer is the default-constructed null edge this function already returns on its other refusal paths, so this reuses the existing 'declined' signal rather than introducing a new one. Related issue: Fixes Open-Cascade-SAS#1431. Tests: New GTest in src/ModelingAlgorithms/TKFillet/GTests/BRepFilletAPI_MakeFillet2d_Test.cxx, calling AddChamfer twice with the identical edge pair through the public API the crash was reported against. Verified both ways: the current pinned kernel (predates this fix) SIGSEGVs on the second call (exit 139); linked with the patched translation unit ahead of the archive, the same call returns a null edge with Status() == ChFi2d_ConnexionError, matching the sibling overload's own answer for an unconnected vertex, and the test passes. How Has This Been Tested? 1. Standalone repro: a rectangular planar face, BRepFilletAPI_MakeFillet2d::AddChamfer called twice with the identical edge pair. On stock master, the second call SIGSEGVs 100% of the time (ComputeChamfer, both edges null). 2. Debug (-O0) single-TU override-link (this file compiled standalone and linked before the OCCT static archive, so the linker resolves this TU's symbols from the override): before the patch, the second call crashes; after, it returns a null edge with Status() == ChFi2d_ConnexionError. 3. The first call in both cases is unaffected: Status() == ChFi2d_IsDone, non-null edge, same geometry before and after. 4. New GTest exercises both directions directly (see above). 5. clang-format clean on both touched/added files.
gsdali
force-pushed
the
fix/705-chfi2d-addchamfer-repeated-pair
branch
from
August 10, 2026 23:56
75fb65b to
50b1018
Compare
Contributor
Author
|
Thanks — pushed a GTest.
|
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.
Description of the change
ChFi2d_Builder::AddChamfer(const TopoDS_Edge& E1, const TopoDS_Edge& E2, double D1, double D2)calls
ChFi2d::FindConnectedEdgesand dereferences the two edges it returns without checking thereturned status first.
FindConnectedEdgesleaves both edges null on every failure path, and asecond call naming the same edge pair hits exactly that: the pair's shared vertex is removed from
the face's wire by the first call's own
BuildNewWire, so the second call's lookup fails and thetwo null edges it returns reach
ComputeChamferunchecked.Adds the same status check the sibling overload,
AddChamfer(const TopoDS_Edge& E, const TopoDS_Vertex& V, double D, double Ang), already has immediately after the identicalFindConnectedEdgescall:chamferis the default-constructed null edge this function already returns on its other refusalpaths (
ChFi2d_Builder_0.cxxlines 83, 89, 95), so this reuses the existing "declined" signalrather than introducing a new one.
Related issue
Fixes #1431.
Type of change
How Has This Been Tested?
BRepFilletAPI_MakeFillet2d::AddChamfercalled twice with the identical edge pair. On stock
master, the second call SIGSEGVs 100% ofthe time (
ComputeChamfer, both edges null).-O0) single-TU override-link (this file compiled standalone and linked before the OCCTstatic archive, so the linker resolves this TU's symbols from the override): before the patch,
the second call crashes; after, it returns a null edge with
Status() == ChFi2d_ConnexionError,matching the sibling overload's own answer for an unconnected vertex.
Status() == ChFi2d_IsDone, non-null edge, samegeometry before and after.
clang-format --dry-run --Werroron the touched file reports only pre-existing violationselsewhere in the file (
Geom2dInt_GInterconstruction, unrelated lines), unchanged in count andcontent before and after this patch; the four added lines are clean.
Checklist:
mirrors the sibling overload's own existing, uncommented idiom line for line
"does not crash"
wrapper project (OCCTSwift), which found this crash through a fillet/chamfer contract audit;
happy to add a DRAW test if maintainers point me at the right harness/fixture convention for
this area