Repository navigation
sn-item: use a weak ref for async callbacks - #218
Open
climashscape wants to merge 1 commit into
Open
climashscape wants to merge 1 commit into
climashscape wants to merge 1 commit into
Conversation
property_proxy_acquired() and get_all_properties_callback() receive a bare SnItem pointer. If the client exits while the call is in flight, handle_sn_item_name_owner_lost() removes the item from the hash table and it is finalized; the callback then writes to freed memory and crashes in g_signal_connect_data. Pass a GWeakRef wrapper instead. The callback takes a temporary strong ref only if the item is still alive, and cleans up on every path. Also fix the cancellation path, which previously fell through to g_signal_connect() instead of returning.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
xapp-sn-watchercrashes with SIGSEGV when a StatusNotifierItem client registers and exits quickly. On Linux Mint 22.3 (xapp 3.2.4+mint22.3, Cinnamon 6.6.9) it happens repeatedly; every crash removes all SNI/XApp status icons from the panel until the watcher is restarted.Real coredump (2026-11-12 20:53:29):
+0xf41dmaps toproperty_proxy_acquired()inxapp-sn-watcher/sn-item.c: the call site is followed byxapp_status_icon_new(), and the stringsCould not get property proxy for %s: %s,g-signalandhighlight-both-menusare referenced there.initialize_item()passes a bareSnItem *to the asyncg_dbus_proxy_new()fororg.freedesktop.DBus.Properties. If the client exits before the callback,handle_sn_item_name_owner_lost()removes the item from the hash table (its only owner), the item is finalized, and the callback dereferences freed memory. TheG_IO_ERROR_CANCELLEDbranch also falls through tog_signal_connect()instead of returning.get_all_properties_callback()has the same bare-pointer problem.The existing 3.2 fix (#201/#214) only covers the cancellation handling in
get_all_properties_callback(); it does not cover this callback.Fix
Use
GWeakReffor the async user data in both callbacks. The callback takes a temporary strong ref only if the item is still alive; if it is gone, it discards the result and returns. Every path frees the error/proxy/weak-ref wrapper. Return on any error, includingG_IO_ERROR_CANCELLED.A weak ref is used instead of
g_object_ref: a strong ref would defer dispose and let an already-removed item create a status icon.Reproduction
Under a private bus with a real
XApp.StatusIconMonitor, register a StatusNotifierItem on a fresh connection and close the connection immediately after the registration reply. Repeat.OK: watcher survived 1000 registrations(also 300 x3).A standalone reproducer script is available and can be added to the PR if wanted.
Notes
3.2-maintenance.masterremovedSnItem.prop_proxy, so this code path does not exist there.