Skip to content

Commit

Permalink
Fix thread race in test-only XPC code. (#28041)
Browse files Browse the repository at this point in the history
The clearRegistry block is touching various members of "self" that should only
be touched on self.workQueue.  But it was being called on whatever queue the
client-provided stopReportsWithController method called its completion on.

The fix is to dispatch to the queue that getProxyHandleWithCompletion is passed,
which is in fact our work queue.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Oct 26, 2023
1 parent aa95deb commit 6ea4dd0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ - (void)deregisterReportHandlersWithController:(id<NSCopying>)controller
[handle.proxy stopReportsWithController:controller
nodeId:nodeID.unsignedLongLongValue
completion:^{
// Make sure handle stays alive until we get to this
// completion (in particular while we are working
// with handle.proxy).
__auto_type handleRetainer = handle;
(void) handleRetainer;
clearRegistry();
dispatch_async(queue, clearRegistry);
}];
} else {
MTR_LOG_ERROR("CHIP XPC connection failed to stop reporting");
Expand Down

0 comments on commit 6ea4dd0

Please sign in to comment.