Skip to content

cosmic-applet-bluetooth panics with .unwrap() on Wayland BrokenPipe, taking down the entire panel and triggering a full session restart #1410

@gabriel-valeriodata

Description

@gabriel-valeriodata

A transient I/O error on the Wayland socket (BrokenPipe, errno 32) is propagated through .unwrap() in libcosmic's applet token handler, panicking the Bluetooth applet thread. Because all panel applets share the cosmic-panel process, the panic cascades: cosmic-panel dies, cosmic-session interprets that as a fatal failure, and the entire user session is torn down and restarted — closing every open application without warning.

A recoverable I/O error should not destroy the user's session.

Environment

  • Distro: Pop!_OS 24.04 LTS (noble)
  • Kernel: 6.18.7-76061807-generic
  • cosmic-applets: 1.0.12~1779200847~24.04~03c302d
  • cosmic-panel: 0.1.0~1779208585~24.04~26fee6c
  • cosmic-session: 1.0.0~1778176227~24.04~495e591
  • cosmic-comp: 0.1~1779211585~24.04~61e677e
  • Session type: Wayland

Steps to reproduce

Not reliably reproducible on demand, but the trigger pattern is clear from the logs:

  1. Leave a COSMIC session running for multiple days with the Bluetooth applet enabled.
  2. Have at least one paired-but-occasionally-unreachable BT device (logs show repeated br-connection-busy / br-connection-page-timeout from bluetoothd).
  3. Eventually, the Wayland socket between the applet and the compositor returns BrokenPipe.
  4. .unwrap() panics the applet thread → cosmic-panel exits → cascading failure of the whole session.

Actual behavior — verbatim from journalctl -b 0

May 21 16:04:09 pop-os cosmic-panel[2207703]: com.system76.CosmicAppletBluetooth: Io error: Broken pipe (os error 32)
May 21 16:04:09 pop-os cosmic-panel[2207703]: com.system76.CosmicAppletBluetooth: thread '<unnamed>' (2208376) panicked at /build/cosmic-applets-UAZ7bD/cosmic-applets-1.0.12~1779200847~24.04~03c302d/vendor/libcosmic/src/applet/token/wayland_handler.rs:167:50:
May 21 16:04:09 pop-os cosmic-panel[2207703]: com.system76.CosmicAppletBluetooth: called `Result::unwrap()` on an `Err` value: OtherError(IoError(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }))
May 21 16:04:09 pop-os cosmic-panel[2207703]: com.system76.CosmicAppletBluetooth: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The cascade that followed:

May 21 16:04:09 cosmic-session: process 'cosmic-files-applet' terminated with signal 11   (SIGSEGV)
May 21 16:04:09 cosmic-session: process 'cosmic-osd' terminated with signal 6             (SIGABRT)
May 21 16:04:09 cosmic-session: process 'cosmic-app-library' terminated with signal 11    (SIGSEGV)
May 21 16:04:09 cosmic-session: process 'cosmic-comp' failed with code 101
May 21 16:04:09 cosmic-session: cosmic-workspaces exited with error 137                   (SIGKILL)
May 21 16:04:11 cosmic-session: Restarting
May 21 16:04:11 cosmic-session: Starting cosmic-session

Net effect: every open application — terminal sessions, browser, editor, chat clients — was force-killed and the user landed in a re-initialized COSMIC session with no opportunity to save work.

Expected behavior

A BrokenPipe on the Wayland socket is a normal, recoverable condition. The applet should:

  1. Log the error.
  2. Attempt to reconnect, or
  3. Gracefully exit only the applet, allowing cosmic-panel to either restart it or run without it.

It should never panic the panel process, and it should certainly never bring down the session.

Additional context

Preceding the panic, the logs show repeated Bluetooth flapping that may be the underlying trigger:

May 21 16:04:25 bluetoothd: src/profile.c:record_cb() Unable to get Hands-Free Voice gateway SDP record: Host is down
May 21 16:04:25 cosmic-panel: com.system76.CosmicAppletBluetooth: bluetooth request error: Bluetooth operation failed: br-connection-page-timeout

--- I'm leaving this distro, by the way. I can't work on such a messy OS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions