Skip to content

sn-item: Fix error handling to address SIGSEGV#201

Merged
mtwebster merged 1 commit into
linuxmint:masterfrom
leigh123linux:dbus_proxy_crash
May 21, 2026
Merged

sn-item: Fix error handling to address SIGSEGV#201
mtwebster merged 1 commit into
linuxmint:masterfrom
leigh123linux:dbus_proxy_crash

Conversation

@leigh123linux
Copy link
Copy Markdown
Member

@leigh123linux leigh123linux commented May 16, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a SIGSEGV in the status notifier item watcher by ensuring in-flight async D-Bus calls are cancelled during object disposal, preventing callbacks from touching cleared proxy state.

Changes:

  • Cancel GCancellable in sn_item_dispose() before clearing proxies to abort in-flight/queued async operations safely.
  • Add a NULL-guard in get_all_properties_callback() to bail out if proxies were cleared before processing results.
Comments suppressed due to low confidence (1)

xapp-sn-watcher/sn-item.c:181

  • Now that dispose() actively cancels item->cancellable, any pending async ops (e.g. the g_dbus_proxy_new() in initialize_item()) will complete with G_IO_ERROR_CANCELLED. In property_proxy_acquired(), the CANCELLED branch currently does not g_error_free(error) and does not return, so it will continue initializing the item with prop_proxy == NULL. Please make the CANCELLED path free the error and return early to avoid leaks and inconsistent state.
    g_cancellable_cancel (item->cancellable);

    g_clear_pointer (&item->sortable_name, g_free);
    g_clear_object (&item->status_icon);
    g_clear_object (&item->prop_proxy);
    g_clear_object (&item->sn_item_proxy);
    g_clear_object (&item->cancellable);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread xapp-sn-watcher/sn-item.c Outdated
Comment thread xapp-sn-watcher/sn-item.c Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread xapp-sn-watcher/sn-item.c
Comment thread xapp-sn-watcher/sn-item.c Outdated
Comment on lines +765 to +769
if (item->prop_proxy == NULL || item->sn_item_proxy == NULL)
{
g_clear_pointer (&properties, g_variant_unref);
return;
}
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

xapp-sn-watcher/sn-item.c:1178

  • With the new dispose-time g_cancellable_cancel(), g_dbus_proxy_new_finish() can now fail with G_IO_ERROR_CANCELLED. In that case this callback currently neither frees error nor returns, and it proceeds with item->prop_proxy == NULL to connect signals/create the status icon/queue updates, which can lead to crashes or inconsistent state. Handle the cancelled case explicitly by freeing error and returning early (and ensure the SnItem ref is released in the same cleanup path).
    item->prop_proxy = g_dbus_proxy_new_finish (res, &error);

    if (error != NULL)
    {
        if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        {
            g_critical ("Could not get property proxy for %s: %s\n",
                        g_dbus_proxy_get_name (item->sn_item_proxy),
                        error->message);
            g_error_free (error);
            return;
        }
    }

Comment thread xapp-sn-watcher/sn-item.c Outdated
Comment on lines +737 to +738
SnItem *item = SN_ITEM (user_data);
g_object_unref (item);
Comment thread xapp-sn-watcher/sn-item.c
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread xapp-sn-watcher/sn-item.c
@leigh123linux leigh123linux changed the title sn-item: cancel in-flight async calls on dispose to fix SIGSEGV sn-item: Fix error handling to address SIGSEGV May 21, 2026
@mtwebster mtwebster merged commit 2212d1c into linuxmint:master May 21, 2026
3 checks passed
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.

3 participants