Skip to content

status-icon: use a weak ref for the ListNames callback - #220

Open
climashscape wants to merge 1 commit into
linuxmint:masterfrom
climashscape:fix/status-icon-weak-ref-master
Open

climashscape wants to merge 1 commit into
linuxmint:masterfrom
climashscape:fix/status-icon-weak-ref-master

Conversation

@climashscape

Copy link
Copy Markdown

This is the master version of the 3.2-maintenance fix.

master still passes the bare XAppStatusIcon * in look_for_status_applet() to on_list_names_completed(). The same use-after-free exists when the owning SnItem is removed while the ListNames call is in flight: the callback then dereferences self->priv->interface_skeleton / self->priv->connection on a freed icon (the 3.2 crash was on_list_names_completed → sync_skeleton → g_object_set, stack libxapp+0x29bea / libxapp+0x2bfdf).

The change is behaviorally identical to the 3.2-maintenance PR: use a GWeakRef as the async user data; bail out if the icon is gone; free the error/result/ref on all paths.

The patch applies to master at 84df382 and builds as xapp 3.4.0. The behavioral reproducer (SNI register + immediate connection close, private bus with a real XApp.StatusIconMonitor) was run against the patched master watcher: OK: watcher survived 300 registrations.

If the branches are kept in sync by cherry-picking, this PR can be skipped in favor of the 3.2-maintenance one.

Related

look_for_status_applet() passes a bare XAppStatusIcon pointer. The
owning SnItem can be removed while ListNames is in flight and drops its
ref, finalizing the icon; on_list_names_completed() then uses freed
memory (g_bus_own_name_on_connection with a stale connection).

Pass a GWeakRef wrapper and bail out if the icon is gone.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant