Skip to content

service/pipewire: guard against null registry proxy during object teardown - #1470

Open
devpryan7792 wants to merge 1 commit into
quickshell-mirror:masterfrom
devpryan7792:fix/pipewire-null-registry-teardown
Open

devpryan7792 wants to merge 1 commit into
quickshell-mirror:masterfrom
devpryan7792:fix/pipewire-null-registry-teardown

Conversation

@devpryan7792

Copy link
Copy Markdown

Describe your changes

Prevents a SIGSEGV during PipeWire teardown when Bluetooth audio disconnects or when a fatal PipeWire error triggers PwRegistry::reset().

Specifically:

  • Destroys child bindable objects (metadata, links, nodes, devices) with safeDestroy() before destroying the registry proxy this->object.
  • Adds guards in PwBindableObject::registryBind() against a null registry, null registry proxy, or id == 0.
  • In PwBindable::bind(), skips executing bindHooks() if registryBind() was unable to obtain a valid proxy.
  • Sets this->id = 0 in PwBindableObject::safeDestroy() before emitting destroying(this).

Closes #1468.

Details and descisions

When a PipeWire error occurs (e.g. error on object 6 with code -14 upon Bluetooth device disconnect), PwConnection::onFatalError() calls PwRegistry::reset().

Previously, reset() immediately destroyed this->object and set it to nullptr. When safeDestroy() then ran on remaining nodes and interfaces, emitting destroying(this) and Qt's delete this triggered property updates and QML bindings (such as PwObjectTracker::setObjects()). That called pwObject->ref() on incoming nodes. When an unbound node entered bind(), PwBindableObject::registryBind() invoked pw_registry_bind(this->registry->object, ...) with a null registry pointer, causing a crash at ldr x0, [x6, #16].

By tearing down child proxies before destroying the parent registry proxy, guarding against null in registryBind(), and ensuring id == 0 during destruction, re-entrant binds during teardown are safely aborted.

Open concerns

None. Build and CTest suite verified locally.

Participation

Happy to address review feedback and maintain/contribute to PipeWire and Wayland service integrations in Quickshell.

…rdown

When PipeWire experiences a fatal error or transport disconnect (e.g.
Bluetooth device disconnection), PwConnection initiates teardown via
PwRegistry::reset(). In that path, the registry proxy was previously
destroyed and nulled prior to safeDestroy() running on child objects.

Destruction of nodes and interfaces triggers QObject notifications and
QML property bindings which can re-evaluate and call PwObjectTracker::setObjects(),
referencing nodes and invoking ref(). If an unbound node enters bind(),
PwBindableObject::registryBind() called pw_registry_bind() with a null
registry pointer, causing a SIGSEGV.

Fix this by:
1. Reordering PwRegistry::reset() so child objects (metadata, links,
   nodes, devices) are torn down before the parent registry proxy is
   destroyed.
2. Guarding PwBindableObject::registryBind() against null registry, null
   registry proxy, or id == 0.
3. Guarding PwBindable::bind() so bindHooks() are not executed if
   registryBind() was unable to allocate a proxy.
4. Setting id = 0 in PwBindableObject::safeDestroy() prior to emitting
   the destroying() signal.

Closes quickshell-mirror#1468

Signed-off-by: Pradyumn jha <devpryan7792@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGSEGV: PwObjectTracker rebinds a node through a null PipeWire registry during teardown

2 participants