Skip to content

BUG: Initialize member in itk::AttributeLabelObject#2660

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
jhlegarreta:FixAttributeLabelObjectUninitializedMember
Jul 22, 2021
Merged

BUG: Initialize member in itk::AttributeLabelObject#2660
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
jhlegarreta:FixAttributeLabelObjectUninitializedMember

Conversation

@jhlegarreta
Copy link
Copy Markdown
Member

@jhlegarreta jhlegarreta commented Jul 21, 2021

Initialize member in itk::AttributeLabelObject.

Fixes:

==6189== Command: /tmp/bld/ITK-build/bin/ITKLabelMapTestDriver
itkAttributeLabelObjectAccessorsTest1
/tmp/bld/ITK-build/ExternalData/Testing/Data/Input/cthead1Label.png
/tmp/bld/ITK-build/ExternalData/Testing/Data/Input/cthead1.png
==6189== Parent PID: 55
==6189==
UMC ==6189== Conditional jump or move depends on uninitialised value(s)
==6189==    at 0x91423DC: __printf_fp_l (in /usr/lib64/libc-2.17.so)
==6189==    by 0x91414D6: vfprintf (in /usr/lib64/libc-2.17.so)
==6189==    by 0x916C178: vsnprintf (in /usr/lib64/libc-2.17.so)
==6189==    by 0x8C5B63C: ??? (in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x8C61CA3: std::ostreambuf_iterator > std::num_put >
>::_M_insert_float(std::ostreambuf_iterator >, std::ios_base&, char, char,
>double) const (in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x8C61F8F: std::num_put >
>::do_put(std::ostreambuf_iterator >, std::ios_base&, char, double) const
>(in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x8C6DB94: std::ostream& std::ostream::_M_insert(double)
(in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x2F0A06:
itk::AttributeLabelObject::PrintSelf(std::ostream&, itk::Indent) const
(itkAttributeLabelObject.h:155)
==6189==    by 0x67D4A99: itk::LightObject::Print(std::ostream&,
itk::Indent) const (itkLightObject.cxx:125)
==6189==    by 0x2E74F9: itkAttributeLabelObjectAccessorsTest1(int,
char**) (itkAttributeLabelObjectAccessorsTest1.cxx:80)
==6189==    by 0x278CF5: main (ITKLabelMapTestDriver.cxx:467)

Raised in:
https://open.cdash.org/viewDynamicAnalysisFile.php?id=8560922

Provide a default initialization to the default constructor.

PR Checklist

@jhlegarreta
Copy link
Copy Markdown
Member Author

Uncovered by #2652.

@github-actions github-actions bot added area:Filtering Issues affecting the Filtering module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances labels Jul 21, 2021
@N-Dekker
Copy link
Copy Markdown
Contributor

Could you also please adjust the default-constructor, with this commit? It now says:

// how to initialize the attribute ?

Your commit answers this question! If possible, please "default" the default-constructor: AttributeLabelObject() = default; But otherwise, at least please remove the outdated comment.

AttributeLabelObject()
{
// how to initialize the attribute ?
}

@jhlegarreta jhlegarreta force-pushed the FixAttributeLabelObjectUninitializedMember branch from 40f9860 to 8afd3d5 Compare July 22, 2021 11:23
@jhlegarreta
Copy link
Copy Markdown
Member Author

Your commit answers this question! If possible, please "default" the default-constructor: AttributeLabelObject() = default; But otherwise, at least please remove the outdated comment.

Good catch. Done in 8afd3d5.

@N-Dekker thanks for the review. Could you please update the necessary sections in the ITK SW Guide to be up-to-date concerning these practices? At least the Development Guideline and Coding Style Guide parts.

Initialize member in `itk::AttributeLabelObject`.

Fixes:
```
==6189== Command: /tmp/bld/ITK-build/bin/ITKLabelMapTestDriver
itkAttributeLabelObjectAccessorsTest1
/tmp/bld/ITK-build/ExternalData/Testing/Data/Input/cthead1Label.png
/tmp/bld/ITK-build/ExternalData/Testing/Data/Input/cthead1.png
==6189== Parent PID: 55
==6189==
UMC ==6189== Conditional jump or move depends on uninitialised value(s)
==6189==    at 0x91423DC: __printf_fp_l (in /usr/lib64/libc-2.17.so)
==6189==    by 0x91414D6: vfprintf (in /usr/lib64/libc-2.17.so)
==6189==    by 0x916C178: vsnprintf (in /usr/lib64/libc-2.17.so)
==6189==    by 0x8C5B63C: ??? (in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x8C61CA3: std::ostreambuf_iterator > std::num_put >
>::_M_insert_float(std::ostreambuf_iterator >, std::ios_base&, char, char,
>double) const (in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x8C61F8F: std::num_put >
>::do_put(std::ostreambuf_iterator >, std::ios_base&, char, double) const
>(in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x8C6DB94: std::ostream& std::ostream::_M_insert(double)
(in /usr/lib64/libstdc++.so.6.0.19)
==6189==    by 0x2F0A06:
itk::AttributeLabelObject::PrintSelf(std::ostream&, itk::Indent) const
(itkAttributeLabelObject.h:155)
==6189==    by 0x67D4A99: itk::LightObject::Print(std::ostream&,
itk::Indent) const (itkLightObject.cxx:125)
==6189==    by 0x2E74F9: itkAttributeLabelObjectAccessorsTest1(int,
char**) (itkAttributeLabelObjectAccessorsTest1.cxx:80)
==6189==    by 0x278CF5: main (ITKLabelMapTestDriver.cxx:467)
```

Raised in:
https://open.cdash.org/viewDynamicAnalysisFile.php?id=8560922

Provide a default initialization to the default constructor.
@jhlegarreta jhlegarreta force-pushed the FixAttributeLabelObjectUninitializedMember branch from 8afd3d5 to 68ecf0d Compare July 22, 2021 11:46
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker left a comment

Choose a reason for hiding this comment

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

Thanks very much @jhlegarreta I'll have another look at the ITK SW Guide when I have some more time.

@dzenanz dzenanz merged commit ce01296 into InsightSoftwareConsortium:master Jul 22, 2021
@jhlegarreta jhlegarreta deleted the FixAttributeLabelObjectUninitializedMember branch July 22, 2021 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants