Skip to content

0033895: fix null surface crash in fixshape#623

Merged
dpasukhi merged 8 commits intoOpen-Cascade-SAS:IRfrom
sander-adamson-cloudnc:CR33895-fixshape-null-surface-crash
Aug 1, 2025
Merged

0033895: fix null surface crash in fixshape#623
dpasukhi merged 8 commits intoOpen-Cascade-SAS:IRfrom
sander-adamson-cloudnc:CR33895-fixshape-null-surface-crash

Conversation

@sander-adamson-cloudnc
Copy link
Copy Markdown
Contributor

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.

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.
@dpasukhi dpasukhi requested review from Copilot and dpasukhi July 18, 2025 13:41
@dpasukhi dpasukhi added 2. Bug Something isn't working 1. Shape Healing Shape healing operation (fixing topology issue with BRep data) labels Jul 18, 2025
@dpasukhi dpasukhi added this to the Release 7.9.2 milestone Jul 18, 2025

This comment was marked as outdated.

sander-adamson-cloudnc and others added 3 commits July 18, 2025 14:57
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>
@dpasukhi
Copy link
Copy Markdown
Member

Thank for the patch.
I will assign for myself and will update a few things in the code.

Best regards, Dmitrii.

@dpasukhi dpasukhi self-assigned this Jul 21, 2025
@sander-adamson-cloudnc
Copy link
Copy Markdown
Contributor Author

Ok thanks Dmitrii!

@dpasukhi dpasukhi requested a review from AtheneNoctuaPt July 30, 2025 07:59
…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 dpasukhi changed the base branch from master to IR July 31, 2025 15:21
@github-project-automation github-project-automation bot moved this from Todo to Integration in Maintenance Aug 1, 2025
@dpasukhi dpasukhi requested a review from Copilot August 1, 2025 08:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Surface.cxx Outdated
Comment thread src/ModelingAlgorithms/TKShHealing/ShapeAnalysis/ShapeAnalysis_Surface.cxx Outdated
@dpasukhi dpasukhi merged commit 5998693 into Open-Cascade-SAS:IR Aug 1, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Integration to Done in Maintenance Aug 1, 2025
@dpasukhi dpasukhi added the 1. Modeling Boolean operations, offsets, primitives, any conversion, brep builders and etc... label Aug 1, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Modeling Boolean operations, offsets, primitives, any conversion, brep builders and etc... 1. Shape Healing Shape healing operation (fixing topology issue with BRep data) 2. Bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants