0033895: fix null surface crash in fixshape#623
Merged
dpasukhi merged 8 commits intoOpen-Cascade-SAS:IRfrom Aug 1, 2025
Merged
Conversation
ShapeFix_Shape crashes with a segfault when given a shape that contains faces without a surface pointer, for example if the shape is tessellated or triangulated, or contains tessellated / triangulated subshapes. I added null checks to the `const Handle(Geom_Surface)&` parameter of the ShapeAnalysis_Surface constructor, and to the analogous parameter of the Init method, in each case throwing a Standard_NullObject exception. Now, ShapeFix_Shape::Perform will throw an exception instead of crashing with a segfault whenever it encounters a face without a surface. I have CLA 1124.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sander Adamson <sander.adamson@cloudnc.com>
…atedTest.cxx Removing the C++ test, will also need to remove it from the CMake system Signed-off-by: Sander Adamson <sander.adamson@cloudnc.com>
Signed-off-by: Sander Adamson <sander.adamson@cloudnc.com>
Member
|
Thank for the patch. Best regards, Dmitrii. |
Contributor
Author
|
Ok thanks Dmitrii! |
…e error handling in ShapeFix and ShapeAnalysis classes. Test bug33895 is moved to modalg_8 and updated according to code changes. Test stp file is moved into separate repository.
dpasukhi
approved these changes
Aug 1, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a segmentation fault in ShapeFix_Shape when processing shapes that contain faces without surface pointers (e.g., tessellated or triangulated geometry). The fix adds null checks to prevent crashes and throws Standard_NullObject exceptions instead of segfaulting when encountering null surfaces.
Key changes include:
- Added null surface validation in ShapeAnalysis_Surface constructor and Init method
- Added null surface checks throughout ShapeFix_Face methods to prevent crashes
- Enhanced robustness by validating surface availability before performing surface-dependent operations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/bugs/modalg_8/bug33895 | Added test case to verify no crash when fixing tessellated geometry |
| src/ModelingAlgorithms/TKShHealing/ShapeFix/ShapeFix_Face.cxx | Added null surface checks and defensive programming throughout face fixing operations |
| src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Wire.cxx | Enhanced null surface validation in wire analysis operations |
| src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Surface.cxx | Added null surface validation in constructor and Init method with warning messages |
dpasukhi
pushed a commit
that referenced
this pull request
Sep 6, 2025
- Added null surface validation in ShapeAnalysis_Surface constructor and Init method - Added null surface checks throughout ShapeFix_Face methods to prevent crashes - Enhanced robustness by validating surface availability before performing surface-dependent operations
dpasukhi
pushed a commit
that referenced
this pull request
Sep 6, 2025
- Added null surface validation in ShapeAnalysis_Surface constructor and Init method - Added null surface checks throughout ShapeFix_Face methods to prevent crashes - Enhanced robustness by validating surface availability before performing surface-dependent operations
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.
ShapeFix_Shape crashes with a segfault when given a shape that contains faces without a surface pointer, for example if the shape is tessellated or triangulated, or contains tessellated / triangulated subshapes.
I added null checks to the
const Handle(Geom_Surface)¶meter of the ShapeAnalysis_Surface constructor, and to the analogous parameter of the Init method, in each case throwing a Standard_NullObject exception.Now, ShapeFix_Shape::Perform will throw an exception instead of crashing with a segfault whenever it encounters a face without a surface.
I have CLA 1124.