Fix race condition in multi_threaded_observable_map test#1550
Open
DefaultRyan wants to merge 2 commits intomasterfrom
Open
Fix race condition in multi_threaded_observable_map test#1550DefaultRyan wants to merge 2 commits intomasterfrom
DefaultRyan wants to merge 2 commits intomasterfrom
Conversation
dmachaj
approved these changes
Mar 19, 2026
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.
There are two issues causing failures in this test, with both of them resulting in the same problem: the background operation does its thing, but never fires the hook, which causes the foreground wait to timeout, releaseing the foreground. Under sufficient load, this can cause the foreground operation to run unsynchronized with the background, causing failures and crashes.
The actual container code still appears to be fine - this is a test-only issue.
First,
concurrency_checked_random_access_iteratoronly overrodeoperator*, but notoperator->. However, this causedGetMany()to not fire a hook becauseiterator::current_value_withlock()retrieves values differently for map values.cppwinrt/strings/base_collections_base.h
Lines 203 to 214 in 481f8f4
Under load, the foreground wait would timeout, allowing it to call
it.GetMany()before the background had initializedit, causing a crash.Fixed by hooking
operator->in the concurrency test iterator.Second, the MoveNext test cases aren't triggering the hook because iterator advancement isn't an operation with a hook. The test was authored to have the
athook trigger the foreground thread, butMoveNext()doesn't trigger this hook.Under load, the foreground Remove/Insert can complete before the background call to
MoveNext(), causingMoveNext()to move to the end of the container, causing the test check to fail.