All of lore.kernel.org
 help / color / mirror / Atom feed
* [bluez/bluez] 03f0f6: obexd: Reference count the phonebook back-end setu...
@ 2026-08-17 16:21 Paul Menzel
  0 siblings, 0 replies; only message in thread
From: Paul Menzel @ 2026-08-17 16:21 UTC (permalink / raw)
  To: linux-bluetooth

  Branch: refs/heads/1147292
  Home:   https://github.com/bluez/bluez
  Commit: 03f0f67b8b04b464cb99f8d8f2f7e5543508be35
      https://github.com/bluez/bluez/commit/03f0f67b8b04b464cb99f8d8f2f7e5543508be35
  Author: Paul Menzel <pmenzel@molgen.mpg.de>
  Date:   2026-08-17 (Mon, 17 Aug 2026)

  Changed paths:
    M Makefile.obexd
    M obexd/plugins/phonebook-dummy.c
    M obexd/plugins/phonebook-ebook.c
    M obexd/plugins/phonebook-tracker.c
    A obexd/plugins/phonebook.c
    M obexd/plugins/phonebook.h

  Log Message:
  -----------
  obexd: Reference count the phonebook back-end setup and teardown

Stopping obexd on Debian sid/unstable with *bluez* 5.87-1 logs a GObject
critical:

    obexd[10687]: Terminating
    systemd[1804]: Stopping obex.service - Bluetooth OBEX service...
    obexd[10687]: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
    systemd[1804]: Stopped obex.service - Bluetooth OBEX service.

Two builtin plugins use the phonebook back-end: pbap (pbap_init() at
obexd/plugins/pbap.c:962, pbap_exit() at :1002) and irmc (irmc_init() at
obexd/plugins/irmc.c:446, irmc_exit() at :473). Each calls phonebook_init()
when it is loaded and phonebook_exit() when it is unloaded, but neither the
callers nor the back-end track ownership of the singleton they share.
plugin_init() therefore sets the back-end up twice and plugin_cleanup()
tears it down twice. A gdb trace of the shutdown path confirms both pairs
of calls.

The dummy back-end tolerates this by accident: phonebook_init() bails out
early when root_folder is already set, and the second phonebook_exit() only
repeats a g_free()/NULL assignment. The ebook back-end, which Debian builds
(*bluez-obexd* depends on *libebook-1.2* and *libedataserver*), does not.
Its phonebook_init() stores three GObject references in static variables
and phonebook_exit() unconditionally drops all three, so the second
teardown unrefs objects that were already finalized. The registry and the
address book are effectively singletons in evolution-data-server and merely
gain a second reference, but e_book_client_connect_sync() hands back a
fresh client on every call, so the first client leaks and the second one is
unreffed twice – hence a single critical rather than three.

Put the ownership tracking in one place instead of duplicating it in every
back-end: phonebook_init() and phonebook_exit() now live in a new shared
obexd/plugins/phonebook.c and reference count the back-end, so only the
first init and the last exit reach it. The back-end entry points are
renamed to phonebook_driver_init()/phonebook_driver_exit() so that they
cannot be called directly by mistake.

Assisted-by: Claude Code:claude-opus-5



To unsubscribe from these emails, change your notification settings at https://github.com/bluez/bluez/settings/notifications

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-17 16:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 16:21 [bluez/bluez] 03f0f6: obexd: Reference count the phonebook back-end setu Paul Menzel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.