-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ThreadSanitizer failure in controller factory. #26824
Merged
andy31415
merged 2 commits into
project-chip:master
from
bzbarsky-apple:controller-factory-locking
May 25, 2023
Merged
Fix ThreadSanitizer failure in controller factory. #26824
andy31415
merged 2 commits into
project-chip:master
from
bzbarsky-apple:controller-factory-locking
May 25, 2023
Conversation
This file contains 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
pullapprove
bot
requested review from
amitnj,
anush-apple,
arkq,
carol-apple,
cecille,
chrisdecenzo,
chshu,
chulspro,
cliffamzn,
CodeChronos928,
Damian-Nordic,
dhrishi,
electrocucaracha,
emargolis,
franck-apple,
gjc13,
harimau-qirex,
harsha-rajendran,
hawk248,
jelderton,
jepenven-silabs,
jmartinez-silabs,
jmeg-sfy,
joonhaengHeo,
jtung-apple,
kkasperczyk-no,
ksperling-apple,
lazarkov and
lpbeliveau-silabs
May 25, 2023 05:35
pullapprove
bot
requested review from
sharadb-amazon,
tcarmelveilleux,
tecimovic,
vijs,
vivien-apple,
woody-apple,
xylophone21,
younghak-hwang,
yufengwangca and
yunhanw-google
May 25, 2023 05:35
bzbarsky-apple
force-pushed
the
controller-factory-locking
branch
from
May 25, 2023 05:36
e8b4fe8
to
57e27e5
Compare
PR #26824: Size comparison from 9f43988 to 57e27e5 Increases (12 builds for bl602, bl702, cc32xx, esp32, psoc6, telink)
Decreases (11 builds for efr32, esp32, psoc6, telink)
Full report (58 builds for bl602, bl702, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
bzbarsky-apple
added a commit
to bzbarsky-apple/connectedhomeip
that referenced
this pull request
May 25, 2023
Until project-chip#26824 is fixed, this fails way too often.
bzbarsky-apple
added a commit
that referenced
this pull request
May 25, 2023
Until #26824 is fixed, this fails way too often.
andy31415
approved these changes
May 25, 2023
The failure looks like this: WARNING: ThreadSanitizer: race on NSMutableArray (pid=11619) Read-only access of NSMutableArray at 0x7b0c0005f5b0 by thread T3: #0 -[__NSArrayM countByEnumeratingWithState:objects:count:] <null>:2 (CoreFoundation:x86_64+0x4a338) #1 -[MTRDeviceControllerFactory(InternalMethods) operationalInstanceAdded:] MTRDeviceControllerFactory.mm:855 (Matter:x86_64+0x1fd2a) #2 MTROperationalBrowser::OnBrowse(_DNSServiceRef_t*, unsigned int, unsigned int, int, char const*, char const*, char const*, void*) MTROperationalBrowser.mm:100 (Matter:x86_64+0x20ee63c) #3 handle_browse_response <null>:2 (libsystem_dnssd.dylib:x86_64+0x3733) #4 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x3316) Previous modifying access of NSMutableArray at 0x7b0c0005f5b0 by main thread: #0 -[__NSArrayM addObject:] <null>:2 (CoreFoundation:x86_64+0x2457a) #1 -[MTRDeviceControllerFactory createController] MTRDeviceControllerFactory.mm:719 (Matter:x86_64+0x1cee3) #2 -[MTRDeviceControllerFactory createControllerOnExistingFabric:error:] MTRDeviceControllerFactory.mm:534 (Matter:x86_64+0x19792) The basic problem is that we are in the middle of adding an object to _controllers on the API consumer thread when on the Matter thread we get our browse notification. The changes here don't aim to lock around all access to _controllers, but just to make sure that our mutations of it can't race with the access on the Matter thread. More coarse locking would need to be done very carefully, given the amount of dispath_sync to the Matter thread we have going on.
bzbarsky-apple
force-pushed
the
controller-factory-locking
branch
from
May 25, 2023 16:10
57e27e5
to
dbcf811
Compare
vivien-apple
approved these changes
May 25, 2023
PR #26824: Size comparison from 4703f74 to dbcf811 Increases (12 builds for bl702, cyw30739, esp32, nrfconnect, psoc6, telink)
Decreases (11 builds for bl602, cc13x4_26x4, cc32xx, efr32, esp32, psoc6, qpg, telink)
Full report (66 builds for bl602, bl702, cc13x2_26x2, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
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.
The failure looks like this:
The basic problem is that we are in the middle of adding an object to _controllers on the API consumer thread when on the Matter thread we get our browse notification.
The changes here don't aim to lock around all access to _controllers, but just to make sure that our mutations of it can't race with the access on the Matter thread. More coarse locking would need to be done very carefully, given the amount of dispath_sync to the Matter thread we have going on.