InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.37k stars 660 forks source link

BUG: Address race condition #4727

Closed blowekamp closed 1 week ago

blowekamp commented 1 week ago

Addresses issue #4711.

When RelabelConnectedRegion is called by ThreadedConnectivity, both outputLabel and requeredLabel are the same value. Don't re-write the same value.

PR Checklist

Refer to the ITK Software Guide for further development details if necessary.

seanm commented 1 week ago

@blowekamp cool, thanks! Do you need me to try with TSan or did you already?

blowekamp commented 1 week ago

@blowekamp cool, thanks! Do you need me to try with TSan or did you already?

Yes, please test to confirm. I have not configured TSan yet.

seanm commented 1 week ago

Yes, please test to confirm.

I'm afraid all 3 tests still fail under TSan.

I have not configured TSan yet.

Which platform/compiler do you use? TSan is quite easy to use with clang on unix-like OS (and with gcc AFAIK).

blowekamp commented 1 week ago

Well that is disappointing.

I am on OSX 12 ARM. Do you have any documentation for using this tool?

seanm commented 1 week ago

Very easy then, just add -fsanitize=thread to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS.

For details: https://clang.llvm.org/docs/ThreadSanitizer.html

blowekamp commented 1 week ago

Very easy then, just add -fsanitize=thread to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS.

For details: https://clang.llvm.org/docs/ThreadSanitizer.html

Yes, that was easy. The SLIC tests now pass local with the thread sanitizer flag enabled now.

seanm commented 1 week ago

Yes, that was easy. The SLIC tests now pass local with the thread sanitizer flag enabled now.

Sweet! Thanks. The change looks reasonable looking to me, but I don't know this code at all.

dzenanz commented 1 week ago

The change is small, but non-trivial. I can't dive now into the code to understand what it does, and to verify the change is OK.

blowekamp commented 4 days ago

@thewtex Looks like this PR was directly merged into release-5.4. Not sure what need to occur now, to get the release and release-5.4 branches is order.

dzenanz commented 4 days ago

Merge release-5.4 to release, then merge release into master?

thewtex commented 4 days ago

@thewtex Looks like this PR was directly merged into release-5.4. Not sure what need to occur now, to get the release and release-5.4 branches is order.

I went ahead and updated release and master -- happy to do so with an @ ping. Docs are also available here: https://docs.itk.org/en/latest/contributing/index.html#merge-a-topic

blowekamp commented 4 days ago

@thewtex Looks like this PR was directly merged into release-5.4. Not sure what need to occur now, to get the release and release-5.4 branches is order.

I went ahead and updated release and master -- happy to do so with an @ ping. Docs are also available here: https://docs.itk.org/en/latest/contributing/index.html#merge-a-topic

Thanks for the doc links. It's not clear to me what currently is the difference between the release and the release-x.x branches, and how to determine is a "patch" should got to just release or to both.

thewtex commented 2 days ago

Thanks for the doc links. It's not clear to me what currently is the difference between the release and the release-x.x branches, and how to determine is a "patch" should got to just release or to both.

release is not version specific, which release-X.X is.

They always go into both.

seanm commented 2 days ago

I went ahead and updated release and master

Meaning this should be reflected in today's cdash, right?

SLICFixture.Blank2DImage is still failing under TSan on my bot: https://open.cdash.org/tests/1617156531

Was it passing locally for you @blowekamp ?

Perhaps you fixed one race, but not all of them?

thewtex commented 2 days ago

Meaning this should be reflected in today's cdash, right?

Yes