Skip to content
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

Darwin Matter.framework should not call back into client code while on the Matter queue #23277

Closed
bzbarsky-apple opened this issue Oct 20, 2022 · 1 comment · Fixed by #23867

Comments

@bzbarsky-apple
Copy link
Contributor

Some of the Darwin APIs do sync dispatch to the Matter queue. That means we must never call out to consumers while on the Matter queue; otherwise we can deadlock.

This is definitely a problem for MTRDeviceAttestationDelegateBridge but also likely for other @protocol bits that are expected to be implemented by consumers. We need to carefully audit all of these and figure out how to call them on non-Matter queues, or at least document the restrictions on what can be done inside the callbacks.

@bzbarsky-apple
Copy link
Contributor Author

bzbarsky-apple commented Dec 1, 2022

Going through our current @protocol implementations:

  • MTRStorage: has to be sync-called from the Matter queue, but we do it via another dispatch queue to serialize the storage access.
  • MTROTAProviderDelegate: Now called async on its own queue, so not an issue.
  • MTRDeviceDelegate: Called async on the caller-provided queue.
  • MTRDeviceAttestationDelegate: Called async, but on the Matter queue. Needs to be fixed to use its own per-bridge queue.
  • MTRDeviceControllerServerProtocol and MTRDeviceControllerClientProtocol: no idea
  • MTRDeviceControllerDelegate/MTRDevicePairingDelegate: Called async on the caller-provided queue.
  • MTRKeypair: has to be sync-called from the Matter queue.
  • MTRNOCChainIssuer: Called on the consumer-provided queue.

So we just need to fix MTRDeviceAttestationDelegate.

bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Dec 2, 2022
…queue.

Also add some documentation to MTRStorage and MTRKeypair about expected callee
behavior.

Partially addresses project-chip#23277
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Dec 5, 2022
…queue.

Also add some documentation to MTRStorage and MTRKeypair about expected callee
behavior.

Partially addresses project-chip#23277
bzbarsky-apple added a commit that referenced this issue Dec 5, 2022
…queue. (#23867)

Also add some documentation to MTRStorage and MTRKeypair about expected callee
behavior.

Partially addresses #23277
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant