Skip to content

Commit

Permalink
Fix Darwin crash with wildcard subscription. (#15941)
Browse files Browse the repository at this point in the history
We were deleting things on the wrong work queue, so ended up deleting
an object while we were in the middle of executing one of its methods.

The fix is to make sure to delete Matter objects on the Matter work queue.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 19, 2023
1 parent 299d32e commit 82175dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/darwin/Framework/CHIP/CHIPDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,12 @@ - (instancetype)initWithPath:(const ConcreteDataAttributePath &)path value:(null
dispatch_async(mQueue, ^{
callback(nil, err);

delete myself;
// Deletion of our ReadClient (and hence of ourselves, since the
// ReadClient has a pointer to us) needs to happen on the Matter work
// queue.
dispatch_async(DeviceLayer::PlatformMgrImpl().GetWorkQueue(), ^{
delete myself;
});
});

mHaveQueuedDeletion = true;
Expand Down

0 comments on commit 82175dd

Please sign in to comment.