Repository navigation
BUG: Read the shared face-count map without inserting in Compute Triangle Face Ids - #1858
Merged
imikejackson merged 1 commit intoOct 30, 2026
Conversation
imikejackson
force-pushed
the
bug/shared-feature-face-concurrent-map
branch
from
October 29, 2026 14:58
b94e54f to
782d573
Compare
imikejackson
approved these changes
Oct 29, 2026
imikejackson
self-requested a review
October 29, 2026 21:37
imikejackson
enabled auto-merge (squash)
October 29, 2026 21:37
imikejackson
approved these changes
Oct 29, 2026
joeykleingers
force-pushed
the
bug/shared-feature-face-concurrent-map
branch
from
October 29, 2026 21:54
782d573 to
95d2c69
Compare
…ngle Face Ids The parallel loop that fills the feature face labels and triangle counts called std::map::operator[] on a map that every worker shares. Row 0 is the reserved (0,0) boundary. When no triangle uses that pair, the row 0 lookup inserted key 0 and could rebalance the tree while other workers searched it. That is a data race. The workers now take the map by const reference and look counts up with find(). A missing entry gives a count of 0, the same value the insert produced, so the output does not change. Two tests cover the change. The first builds the map from keys 2 and 1, so that inserting key 0 would rotate the tree, and runs the filter 300 times. Under ThreadSanitizer the old code reported a write to the map from inside the parallel loop in every run; the fixed code reported none. The second uses a real (0,0) pair and checks that the reserved row keeps its count. Fixes BlueQuartzSoftware#1772 Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
imikejackson
force-pushed
the
bug/shared-feature-face-concurrent-map
branch
from
October 30, 2026 13:04
95d2c69 to
91d2f8c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Compute Triangle Face Ids fills the feature face labels and triangle counts in a parallel loop. Every worker read the shared face-count map with
std::map::operator[]. Row 0 is the reserved(0,0)boundary. When no triangle uses that pair, the row 0 lookup inserted key 0 and could rebalance the tree while other workers searched it. That is a data race and undefined behavior on every platform. The workers now only read the map, and the filter output does not change. 2 files changed, +112 / −4 lines.1. Read-only map lookup in the parallel loop
src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SharedFeatureFace.cpp—SharedFeatureFaceImplSharedFeatureFaceImpltakes the face-count map byconstreference and looks each count up withfind(). A missing entry gives a count of 0, the same value the old insert produced. The map is built serially before the parallel loop starts and is not changed after that.2. Regression tests
src/Plugins/SimplnxCore/test/SharedFeatureFaceTest.cpp— two new test cases and a shared helper,ExecuteAndCheckLabelPairsSharedFeatureFace: Missing zero pair rotation raceuses first-seen pairs(0,2)and(0,1), so the map holds keys 2 and 1 and an insert of key 0 would rotate the tree at its root. It runs the filter 300 times and checks every ID, label and count, plus the tuple shapes of the outputs. It takes about 0.04 s in a Release build.SharedFeatureFace: Real zero pair countsuses a real(0,0)pair and checks that the reserved row and the real row both report its count of 2.A plain test cannot fail on a data race reliably, so the race was checked with ThreadSanitizer on macOS arm64 (simplnx instrumented, TBB not instrumented). With the old lookup, the first test reported a write to the map from inside the parallel loop in every run (15 of 15 runs across two versions of the test). With the fix, no run reported one (15 runs). The other ThreadSanitizer warnings come from TBB's own scheduler, which is not instrumented, and appear with and without the fix. MSVC has no ThreadSanitizer, so on Windows the check is that the tests pass.
Test plan
SimplnxCore::SharedFeatureFace*tests pass on macOS arm64 Release (3/3)Related Issue
Closes #1772