wireplumber icon indicating copy to clipboard operation
wireplumber copied to clipboard

libspa-bluez5 crash (device_set_update_asha) when suspending while a paired BLE/ASHA earbud is present

Open devgtv opened this issue 2 months ago • 1 comments

Summary

WirePlumber segfaults inside PipeWire's BlueZ5 plugin (libspa-bluez5.so) whenever the system suspends while a BLE/ASHA earbud is paired (but not connected). The crashing frame is device_set_update_asha() in spa/plugins/bluez5/bluez5-device.c:1010, reached from WirePlumber's synchronous wp_spa_device_enum_params_sync calls. Reproduced 3 times; all occurred right at the suspend transition, and the first happened hours after the 0.5.15 → 0.5.17 upgrade.

Environment

  • Arch Linux (Omarchy), desktop Hyprland/uwsm
  • kernel linux 7.2.3.arch1-3
  • pipewire 1:1.6.8-1 (libspa-bluez5.so)
  • wireplumber 0.5.17-1 — upgraded 2026-09-10 07:26, hours before the first crash
  • bluez 5.87-2
  • Paired BLE earbud "zero red" (84:AC:60:45:D7:D7, vendor 0x05d6, product 0xa024), not connected, exposing an ASHA profile

Reproduction

  1. Pair a BLE earbud exposing ASHA, leave it disconnected.
  2. Suspend the machine.
  3. WirePlumber dies with SIGSEGV during the BlueZ2/BlueZ5 device teardown; systemd restarts the user service.

Crashes on this machine (all at the suspend moment):

When Context
2026-09-10 14:53 suspend (omarchy-sleep-lock restart), same faulting frame libspa-bluez5.so+0x4121e
2026-09-10 21:26 suspend while bluetooth.service was being stopped
2026-09-13 07:07 systemd: Reached target Suspend; bluetoothd later logged connect to 84:AC:60:45:D7:D7: Host is down

Symbolized backtrace (Arch debuginfod)

#0  device_set_update_asha  bluez5-device.c:1010
#1  device_set_get_info      bluez5-device.c:1160  (inlines device_set_get_dset_info)
#2  build_profile            bluez5-device.c:2067
#3  impl_enum_params         bluez5-device.c:2782
#4  wp_spa_device_enum_params_sync  (libwireplumber-0.5)
#5  lua scripting switchboard — enum-params on the BlueZ SPA device (libwireplumber-module-lua-scripting + liblua)
    ... main loop ...

si_code is SI_KERNEL; signal SIGSEGV.

Analysis

The fault is at bluez5-device.c:1010:

spa_bt_for_each_set_member(s, set) {
    ...
    if (!(s->device->connected_profiles & SPA_BT_PROFILE_ASHA_SINK))   // <- crash
        continue;

s->device is a stale pointer: the device object is freed during Bluetooth teardown on suspend, but an ASHA set membership still references it, and WirePlumber's synchronous enum-params (device_set_get_info for DEVICE_PROFILE_ASHA, reached via impl_enum_params) dereferences it. This looks like a use-after-free against device teardown. Note device_set_update() is called with a stack-allocated struct device_set dset (device_set_get_info line 1169), whose members hold device pointers — so the freed-device race is in the profile-enumeration path, not a set-lifetime bug in WirePlumber itself.

Expected behavior

WirePlumber should survive suspend/resume regardless of Bluetooth device state.

Workaround

Forgetting the unused earbud avoids the crash. The plugin should not dereference stale device pointers during teardown.

Filed by big-pickle via opencode.

devgtv avatar Sep 13 '26 23:09 devgtv

The official repository for the project is at https://gitlab.freedesktop.org/pipewire/wireplumber/

ford-prefect avatar Sep 21 '26 15:09 ford-prefect