Skip to content

itkMaskFeaturePointSelectionFilter and itkBlockMatchingImageFilter#2

Closed
fuentesdt wants to merge 3 commits intoInsightSoftwareConsortium:masterfrom
fuentesdt:8d436a795b74268bfae07d3e8d1af59c9f8fa79e
Closed

itkMaskFeaturePointSelectionFilter and itkBlockMatchingImageFilter#2
fuentesdt wants to merge 3 commits intoInsightSoftwareConsortium:masterfrom
fuentesdt:8d436a795b74268bfae07d3e8d1af59c9f8fa79e

Conversation

@fuentesdt
Copy link
Contributor

Hi,

I've found attached patch useful to control the distribution of the feature point selection and allow different image sizes in the block match

nocnokneo pushed a commit to GEHC-Surgery/ITK that referenced this pull request Mar 12, 2013
This addresses bug reported here:

https://itk.icts.uiowa.edu/jira/browse/HISTITK-812

The problem comes up because the ImageSeriesReader re-uses one
instance of the ImageIO to read all files, and the GDCMImageIO uses
its own in-built MetaDataDictionary to record all the DICOM tags. It
was populating the dictionary without first clearing it, so if file InsightSoftwareConsortium#1
had a particular DICOM tag, but file InsightSoftwareConsortium#2 did not, the tag would still
show up in the MetaDataDictionary for file InsightSoftwareConsortium#2.

This is fixed by adding a Clear method to MetaDataDictionary, and
calling it in GDCMImageio::GetImageInformation before populating the
MetaDataDictionary with DICOM tags.

Change-Id: I26c6c16719ceb848ae69f6220fa3c78d524a8316
@fuentesdt
Copy link
Contributor Author

sorry, this has been moved to the gerrit system

http://review.source.kitware.com/#/c/10224/

kwrobot pushed a commit that referenced this pull request Oct 9, 2013
From Coverity Scan:

  CID 1081058 (#2-1 of 4): Out-of-bounds write (OVERRUN)
  CID 1081058 (#3 of 4): Out-of-bounds write (OVERRUN)
  CID 1081058 (#4 of 4): Out-of-bounds write (OVERRUN)
  6. overrun-local: Overrunning array of 2 4-byte elements at element index 2
     (byte offset 8) by dereferencing pointer "x + j".

Change-Id: Ic3669d48624559509f594dc7f82f4caa2cd1b601
kwrobot pushed a commit that referenced this pull request Nov 8, 2013
CID 1103199 (#1 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 35 byte destination string
"hdr->hospital" by writing 2049 bytes from "tmpStr"

CID 1103199 (#2 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 32 byte destination string
"hdr->scanId" by writing 2049 bytes from "tmpStr".

CID 1103199 (#3 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 32 byte destination string
"hdr->patientId" by writing 2049 bytes from "tmpStr".

CID 1103199 (#4 of 4): Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 32 byte destination string
"hdr->date" by writing 2049 bytes from "tmpStr".

In all cases, strcpy was replaced with strncpy.

Change-Id: I9955d3c34970b89dfddaa233dfbcb8943166f1be
@thewtex
Copy link
Member

thewtex commented Jul 15, 2014

Moved to Gerrit.

@thewtex thewtex closed this Jul 15, 2014
jcfr added a commit to jcfr/ITK that referenced this pull request Dec 16, 2015
…tern".

This commit updates explicit instantiation to use "extern" keyword similarly
to what was done in InsightSoftwareConsortium/ITK@b72726c (BUG: Explicitly
instantiate common MetaDataObjects).

By using the recommended approach for template instantiation, this commit
should also fix TransformReadWriteTest where TransformIO failed to be
successfully instantiated. Here is the error that was reported when the
was compiled on MacOSX using clang-6.0:

  libc++abi.dylib: terminating with uncaught exception of type itk::ExceptionObject: /scratch/dashboards/MacOSX-clang6/ITK/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx:212:
  itk::ERROR: TransformFileWriterTemplate(0x7fa552100f10): The input of writer should be whether a double precision or a single precision transform type. Called from TransformFileWriterTemplate<double,double$

It also updates IOTransformDCMTK remote module to include a similar fix.

Note InsightSoftwareConsortium#1:

To shut up the following warning from gcc, context specific "pragma GCC
diagnostic" preprocessor instructions have been added:

  warning: type attributes ignored after type is already defined [-Wattributes]

This is most likely specific to gcc (see issue #39159), and at the time
of this commit there were no resolution or information about gcc version
where the "problem" is addressed.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39159

For that reason, the "pragma GCC diagnostic" is applied in-conditionally
of the gcc version being used.

Note InsightSoftwareConsortium#2:

While "extern" is only part of the c++ standard starting with c++11 (see
section 14.7.2 of the standard), it is supported by Visual Studio 2008,
GCC and Clang using compiler specific extension in earlier version:

* Visual Studio 2008: https://msdn.microsoft.com/en-us/library/by56e477(v=vs.90).aspx

* Gcc: https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Template-Instantiation.html#Template-Instantiation

* Clang (since v2.9): http://clang.llvm.org/cxx_status.html

For completeness, initial draft of the "extern" keyword were first
introduced in 2003 [1] and then revised in 2006 [2], and ultimately
standardized in c++11 [3]:

[1] N1448: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1448.pdf
[2] N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
[3] N3242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/

See InsightSoftwareConsortium#3393

Suggested-by: Bradley Lowekamp <blowekamp@mail.nih.gov>
Co-authored-by: Bradley Lowekamp <blowekamp@mail.nih.gov>

Change-Id: I2e3ca2843c500b9bb60bbffc5f3629bc5be0a6fd
kwrobot referenced this pull request in Kitware/ITK Dec 17, 2015
…tern".

This commit updates explicit instantiation to use "extern" keyword similarly
to what was done in InsightSoftwareConsortium/ITK@b72726c (BUG: Explicitly
instantiate common MetaDataObjects).

By using the recommended approach for template instantiation, this commit
should also fix TransformReadWriteTest where TransformIO failed to be
successfully instantiated. Here is the error that was reported when the
was compiled on MacOSX using clang-6.0:

  libc++abi.dylib: terminating with uncaught exception of type itk::ExceptionObject: /scratch/dashboards/MacOSX-clang6/ITK/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx:212:
  itk::ERROR: TransformFileWriterTemplate(0x7fa552100f10): The input of writer should be whether a double precision or a single precision transform type. Called from TransformFileWriterTemplate<double,double$

It also updates IOTransformDCMTK remote module to include a similar fix.

Note #1:

To shut up the following warning from gcc, context specific "pragma GCC
diagnostic" preprocessor instructions have been added:

  warning: type attributes ignored after type is already defined [-Wattributes]

This is most likely specific to gcc (see issue #39159), and at the time
of this commit there were no resolution or information about gcc version
where the "problem" is addressed.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39159

For that reason, the "pragma GCC diagnostic" is applied in-conditionally
of the gcc version being used.

Note #2:

While "extern" is only part of the c++ standard starting with c++11 (see
section 14.7.2 of the standard), it is supported by Visual Studio 2008,
GCC and Clang using compiler specific extension in earlier version:

* Visual Studio 2008: https://msdn.microsoft.com/en-us/library/by56e477(v=vs.90).aspx

* Gcc: https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Template-Instantiation.html#Template-Instantiation

* Clang (since v2.9): http://clang.llvm.org/cxx_status.html

For completeness, initial draft of the "extern" keyword were first
introduced in 2003 [1] and then revised in 2006 [2], and ultimately
standardized in c++11 [3]:

[1] N1448: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1448.pdf
[2] N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
[3] N3242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/

See InsightSoftwareConsortium#3393

Suggested-by: Bradley Lowekamp <blowekamp@mail.nih.gov>
Co-authored-by: Bradley Lowekamp <blowekamp@mail.nih.gov>

Change-Id: I2e3ca2843c500b9bb60bbffc5f3629bc5be0a6fd
kwrobot referenced this pull request in Kitware/ITK Jun 17, 2016
This addresses Coverity issue:

CID 1355469 (#2-1 of 2): Result is not floating-point
(UNINTENDED_INTEGER_DIVISION)integer_division: Dividing integer expressions
error2 and 10U, and then converting the integer quotient to type double. Any
remainder, or fractional part of the quotient, is ignored.

Change-Id: I82a45f68db297e18c8ff9392e8284ea19a7ec603
kwrobot pushed a commit that referenced this pull request Aug 15, 2017
Bradley Lowekamp (7):
      BUG: Always request the full input image
      ENH: replace run-time check of dimension with concept check
      ENH: Prefer raw pointers in pipeline methods
      ENH: Prefer FillBuffer over iterator loop
      ENH: Remove unneeded negative input
      COMP: Fix warning about variable index being shadowed
      Merge pull request #3 from blowekamp/FixShadowWarning

Francois Budin (2):
      Merge pull request #1 from
      blowekamp/PipelineFixesAndImprovements
      Merge pull request #2 from blowekamp/Improvements

Change-Id: Ica14efa46f5ee2ef7d38ab9b22999f69f98b3eb6
kwrobot pushed a commit that referenced this pull request Aug 17, 2017
Bradley Lowekamp (7):
      BUG: Always request the full input image
      ENH: replace run-time check of dimension with concept check
      ENH: Prefer raw pointers in pipeline methods
      ENH: Prefer FillBuffer over iterator loop
      ENH: Remove unneeded negative input
      COMP: Fix warning about variable index being shadowed
      Merge pull request #3 from blowekamp/FixShadowWarning

Francois Budin (2):
      Merge pull request #1 from
      blowekamp/PipelineFixesAndImprovements
      Merge pull request #2 from blowekamp/Improvements

Change-Id: Ica14efa46f5ee2ef7d38ab9b22999f69f98b3eb6
aylward added a commit to HastingsGreer/ITK that referenced this pull request Feb 9, 2019
…patialObject

Arrow, Ellipse, Box, Polygon[Group]
fbordignon added a commit to fbordignon/ITK that referenced this pull request Jan 20, 2023
Hello, I was having trouble with an external python calling the itk function as shared below. The ?? sometimes indicates a callback but to be sure I searched all instances of H5VL_group_close and only H5G__close_cb was calling it and it is currently unmangled. I will test this soon and report back.

<details>

```
#0  0x00007febfdaa8b49 in itk_H5CX_get_vol_wrap_ctx () from /home/gabriel/g/bin/../lib/GeoSlicer-5.1/libitkhdf5-shared-5.3.so.1
InsightSoftwareConsortium#1  0x00007febfdd23a44 in itk_H5VL_set_vol_wrapper () from /home/gabriel/g/bin/../lib/GeoSlicer-5.1/libitkhdf5-shared-5.3.so.1
InsightSoftwareConsortium#2  0x00007febfdd1870b in itk_H5VL_group_close () from /home/gabriel/g/bin/../lib/GeoSlicer-5.1/libitkhdf5-shared-5.3.so.1
InsightSoftwareConsortium#3  0x00007febfdb4b11d in ?? () from /home/gabriel/g/bin/../lib/GeoSlicer-5.1/libitkhdf5-shared-5.3.so.1
InsightSoftwareConsortium#4  0x00007fead7b7d480 in H5I_dec_ref () from /home/gabriel/g/lib/Python/lib/python3.9/site-packages/h5py/../h5py.libs/libhdf5-346dbfc8.so.200.1.0
InsightSoftwareConsortium#5  0x00007fead7b7d544 in H5I_dec_app_ref () from /home/gabriel/g/lib/Python/lib/python3.9/site-packages/h5py/../h5py.libs/libhdf5-346dbfc8.so.200.1.0
InsightSoftwareConsortium#6  0x00007fead7b79fd1 in H5Idec_ref () from /home/gabriel/g/lib/Python/lib/python3.9/site-packages/h5py/../h5py.libs/libhdf5-346dbfc8.so.200.1.0
```
</details>
seanm added a commit that referenced this pull request Apr 29, 2024
Found with thread sanitizer (TSan) running the `itkANTSNeighborhoodCorrelationImageToImageRegistrationTest` unit test.

There was already a `m_ANTSAssociateOnceFlag` flag for use with `std::call_once`, so I just used that in this place too (it's already used elsewhere).

Partial backtrace from TSan:

```
WARNING: ThreadSanitizer: data race (pid=79176)
  Write of size 8 at 0x000108f02240 by thread T2:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)

  Previous write of size 8 at 0x000108f02240 by thread T14:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)
```
seanm added a commit that referenced this pull request May 30, 2024
Found with thread sanitizer (TSan) running the `itkANTSNeighborhoodCorrelationImageToImageRegistrationTest` unit test.

There was already a `m_ANTSAssociateOnceFlag` flag for use with `std::call_once`, so I just used that in this place too (it's already used elsewhere).

Partial backtrace from TSan:

```
WARNING: ThreadSanitizer: data race (pid=79176)
  Write of size 8 at 0x000108f02240 by thread T2:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)

  Previous write of size 8 at 0x000108f02240 by thread T14:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)
```
seanm added a commit to seanm/ITK that referenced this pull request Jul 28, 2024
Found with thread sanitizer (TSan) running the `itkANTSNeighborhoodCorrelationImageToImageRegistrationTest` unit test.

There was already a `m_ANTSAssociateOnceFlag` flag for use with `std::call_once`, so I just used that in this place too (it's already used elsewhere).

Partial backtrace from TSan:

```
WARNING: ThreadSanitizer: data race (pid=79176)
  Write of size 8 at 0x000108f02240 by thread T2:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    InsightSoftwareConsortium#1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    InsightSoftwareConsortium#2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    InsightSoftwareConsortium#3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    InsightSoftwareConsortium#4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)

  Previous write of size 8 at 0x000108f02240 by thread T14:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    InsightSoftwareConsortium#1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    InsightSoftwareConsortium#2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    InsightSoftwareConsortium#3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    InsightSoftwareConsortium#4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants