Skip to content

CoreBluetooth: reachable panics in service discovery kill the CB thread #487

Description

@qdot

Two reachable panics in CoreBluetooth discovery run on the CB event-loop thread. When they fire, the thread dies and every subsequent/in-flight operation hangs or fails with "Channel closed".

  1. src/corebluetooth/internal.rs check_discovered (~L345): panic!("We should still have a future at this point!"). set_characteristic_descriptors calls check_discovered whenever all characteristics are discovered; after the first discovery completes services_discovered_future_state is None, so any late descriptor callback (re-discovery, included service that is also primary, see Race condition causes panic on subscription in CoreBluetooth #167) panics.
  2. internal.rs set_characteristics (~L276): .expect("Got characteristics for a service we don't know about"). central_delegate.rs requests characteristics for included services, which aren't in the service map from discoverServices(nil); also reachable after on_services_modified clears services while characteristic callbacks are in flight.

Fix direction: treat both as benign (trace-log and ignore / no-op when there is no waiting future or unknown service).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcorebluetooth (macos/ios)Issues related to the MacOS/iOS CoreBluetooth impl

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions