[iOS][Fixed] Use std::atomic for eliminating races in RCTCxxBridge #45558
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:
As explained in #45280,
TSan
picks up data races related to concurrent read/write to fields inRCTCxxBridge
. See this report for reference:In order to fix the data races,
std::atomic
instead of primitive boolean types.In order to reproduce my findings and verify fix:
git revert -n 11c09fdc7c442dd694909bebbbc8f21c3e69edf2
._loading
,_moduleRegistryCreated
, and_valid
.. Continue execution if other breakpoints are hit before this breakpoint.NB! While this will fix data races, it will not fix potential race conditions. I have not encountered bugs related to race conditions in
RCTCxxBridge
, but given the nature of how it is made use of concurrently, it is, in my opinion, plausible.Changelog:
[iOS][Fixed] Use std::atomic for eliminating races in RCTCxxBridge.
Test Plan:
I believe there are existing Unit tests in place for verifying this fix.