From 50c5485efce6a863696d2ad8adee199e5d612136 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 9 Feb 2022 12:15:03 +0100 Subject: [PATCH] proxy: don't remove the hooks, but report them leaking When a client forgets to remove a hook, report them leaked in the debug log. This is not a problem because we don't usually add our own removed hook for proxies. The problem is that we can't forcibly remove them with _clean() from _destroy() because the hooks might be emitting the removed event or the object listener. We could try to remove them in the final unref but it seems some apps free their data before that and then we unref invalid memory. --- src/pipewire/proxy.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pipewire/proxy.c b/src/pipewire/proxy.c index 8c20b3d58..bdcbb67cc 100644 --- a/src/pipewire/proxy.c +++ b/src/pipewire/proxy.c @@ -256,9 +256,6 @@ void pw_proxy_destroy(struct pw_proxy *proxy) pw_proxy_emit_destroy(proxy); } - spa_hook_list_clean(&proxy->listener_list); - spa_hook_list_clean(&proxy->object_listener_list); - pw_proxy_unref(proxy); } @@ -291,6 +288,8 @@ void pw_proxy_remove(struct pw_proxy *proxy) SPA_EXPORT void pw_proxy_unref(struct pw_proxy *proxy) { + struct spa_hook *h; + assert(proxy->refcount > 0); if (--proxy->refcount > 0) return; @@ -298,6 +297,12 @@ void pw_proxy_unref(struct pw_proxy *proxy) pw_log_debug("%p: free %u", proxy, proxy->id); /** client must explicitly destroy all proxies */ assert(proxy->destroyed); + + spa_list_for_each(h, &proxy->object_listener_list.list, link) + pw_log_debug("%p: leaked proxy object listener %p id:%d", proxy, h, proxy->id); + spa_list_for_each(h, &proxy->listener_list.list, link) + pw_log_debug("%p: leaked proxy listener %p id:%d", proxy, h, proxy->id); + free(proxy); }