-
-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PointSet::SetPoints(PointsVectorContainer *)
overload leads to undefined behavior
#4848
Comments
Aims to mitigate issue InsightSoftwareConsortium#4848 "`PointSet::SetPoints(PointsVectorContainer *)` overload leads to undefined behavior"
Aims to mitigate issue #4848 "`PointSet::SetPoints(PointsVectorContainer *)` overload leads to undefined behavior"
When the points are specified by a flat VectorContainer of coordinates, passing those points to `SetPoints` may lead to undefined behavior. `SetPointsByCoordinates` is in that case preferred. - Partially addresses issue InsightSoftwareConsortium#4848 "`PointSet::SetPoints(PointsVectorContainer *)` overload leads to undefined behavior"
The SetPoints calls in two serialization tests appear unsafe, as was reported by issue InsightSoftwareConsortium#4848 "`PointSet::SetPoints(PointsVectorContainer *)` overload leads to undefined behavior". With this commit, those tests try both using SetPointsByCoordinates and using the unsafe SetPoints overload.
Note that the problem has moved to here since #4867: ITK/Modules/Core/Common/include/itkPointSetBase.hxx Lines 72 to 73 in ec75692
|
Would it be OK if we would just deprecate, and eventually remove this particular |
Yes, it can be deprecated. But for the future, we should think of a way for Python to allow direct point setting without creating a new copy. Because there are use cases where the meshes can be in GB size and for performing some simple filtering, a new copy would be too much. |
Description
PointSet::SetPoints(PointsVectorContainer * points)
internally casts its argument to aPointsContainer *
:ITK/Modules/Core/Common/include/itkPointSet.hxx
Line 76 in 9a5dade
This leads to undefined behavior, when the
PointsVectorContainer
object is being used as aPointsContainer
object.Steps to Reproduce
The test code already has undefined behavior, even if it might just work on the currently tested platforms:
ITK/Modules/Core/Common/test/itkPointSetTest.cxx
Lines 102 to 127 in 9a5dade
Versions
PointSet::SetPoints(PointsVectorContainer *)
overload is introduced by pull request ENH: Support for Mesh serialization #3154 commit 6827360 "ENH: Adding SetPoints in PointSet for 1D input array", merged on Mar 16, 2022, and included with both v5.3.0 and v5.4.0.Additional Information
Discussed before at #3154 (comment), with @PranjalSahu
The text was updated successfully, but these errors were encountered: