-
-
Notifications
You must be signed in to change notification settings - Fork 726
COMP: Fix uninitialized memory Valgrind defects #3933
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
Changes from all commits
0aef90c
a14a495
cbbbe49
d741ad0
05c7c5a
53d8dbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,16 +124,16 @@ class ITK_TEMPLATE_EXPORT ParallelSparseFieldCityBlockNeighborList | |
| Print(std::ostream & os, Indent indent) const; | ||
|
|
||
| private: | ||
| char m_Pad1[128]; | ||
| unsigned int m_Size; | ||
| RadiusType m_Radius; | ||
| std::vector<unsigned int> m_ArrayIndex; | ||
| std::vector<OffsetType> m_NeighborhoodOffset; | ||
| char m_Pad1[128]{}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jhlegarreta @dzenanz Please wait, before merging. I'm still considering to propose adjusting the ITK Coding Style Guide, to exclude padding bytes from Update: please check: InsightSoftwareConsortium/ITKSoftwareGuide#192
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could make it clearer that these are just padding bytes that do not need to be initialized by renaming
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @N-Dekker I agree with our last comment here. the m_Pad1 is not really a state variable of the class. It is a solution to a problem that happens to use a char array to enforce performance gains, but does not represent the state of the class. These pad variables should have good documentation that they are excluded from the "standard rules" applied to member variables that represent the state of the object.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @hjmjohnson By the way, it looks like C++17 offers some extra functionality to prevent false sharing. From https://en.cppreference.com/w/cpp/thread/hardware_destructive_interference_size:
This would prevent false sharing between
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When did we move to C++14? Maybe it is time to move to C++17?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was almost 2 years ago. I suggest making a forum topic about move to C++17, to see what others think about it. Perhaps describe implications on compiler support, and other similar considerations in the post.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR has other improvements which are not contentious. I will merge this. @N-Dekker can then make a follow-up PR which just deals with Padding bytes. |
||
| unsigned int m_Size{ 2 * Dimension }; | ||
| RadiusType m_Radius{}; | ||
| std::vector<unsigned int> m_ArrayIndex{}; | ||
| std::vector<OffsetType> m_NeighborhoodOffset{}; | ||
|
|
||
| /** An internal table for keeping track of stride lengths in a neighborhood, | ||
| * i.e. the memory offsets between pixels along each dimensional axis. */ | ||
| unsigned int m_StrideTable[Dimension]; | ||
| char m_Pad2[128]; | ||
| unsigned int m_StrideTable[Dimension]{}; | ||
| char m_Pad2[128]{}; | ||
| }; | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.