Crash when removing a disconnected account

Do we need a NULL check here?

Thread 1 “pidgin3” received signal SIGSEGV, Segmentation fault.
0x00007ffff7a953c1 in g_type_check_instance_is_fundamentally_a () from /usr/lib64/libgobject-2.0.so.0
(gdb) bt 12
#0  0x00007ffff7a953c1 in g_type_check_instance_is_fundamentally_a () at /usr/lib64/libgobject-2.0.so.0
#1  0x00007ffff7a74eab in g_object_unref () at /usr/lib64/libgobject-2.0.so.0
#2  0x00007ffff7f62f19 in pidgin_account_manager_row_finalize (obj=0x55555645f760) at ../pidgin/pidginaccountmanagerrow.c:224
#3  0x00007ffff7a7516e in g_object_unref () at /usr/lib64/libgobject-2.0.so.0
#4  0x00007ffff729bbc1 in ??? () at /usr/lib64/libgtk-4.so.1
#5  0x00007ffff727b9b0 in ??? () at /usr/lib64/libgtk-4.so.1
#6  0x00007ffff7282518 in ??? () at /usr/lib64/libgtk-4.so.1
#7  0x00007ffff72918da in ??? () at /usr/lib64/libgtk-4.so.1
#8  0x00007ffff72918da in ??? () at /usr/lib64/libgtk-4.so.1
#9  0x00007ffff72918da in ??? () at /usr/lib64/libgtk-4.so.1
#10 0x00007ffff72918da in ??? () at /usr/lib64/libgtk-4.so.1
#11 0x00007ffff72918da in ??? () at /usr/lib64/libgtk-4.so.1
(More stack frames follow…)
(gdb) f 2
#2  0x00007ffff7f62f19 in pidgin_account_manager_row_finalize (obj=0x55555645f760) at ../pidgin/pidginaccountmanagerrow.c:224
224             g_clear_object(&row->account);
(gdb) p row
$1 = 0x55555645f760
(gdb) p row->account
$2 = 0x0
(gdb) list
219             PidginAccountManagerRow \*row = PIDGIN_ACCOUNT_MANAGER_ROW(obj);
220
221             g_clear_object(&row->bindings);
222             g_clear_object(&row->signals);
223
224             g_clear_object(&row->account);
225             g_clear_pointer(&row->status, g_free);
226
227             G_OBJECT_CLASS(pidgin_account_manager_row_parent_class)->finalize(obj);
228     }

I’m not just adding it because I’m not sure if there might be a more appropriate solution. This crash happened like this (while no credentials were saved):

  • add a purple-spasm account which doesn’t connect because there’s no credential manager configured
  • immediately remove that account again

Is row→account even supposed to be NULL, I mean even if the connection fails, the account should still be there?

g_clear_pointer does a null check before calling g_object_unref. The account shouldn’t even be null though. What revision is this (hg id) ?

Output of hg id:

1c9c608b8db9 tip

Hmm I cant’ seem to reproduce. What protocol was the account?

It was purple-spasm but I just tried again and it didn’t crash this time.

Was the plugin loaded properly? If the plugin failed to load that could cause some weird issues, but the account shouldn’t be null regardless.

It looks like it, here’s the output prior to the crash. There are some failed assertions.

main-Message: 20:17:23.192: Launching Pidgin 2.94.1-dev with libpurple 2.94.1-dev
Purple-CredentialManager-Message: 20:17:23.214: set active provider to 'noop-provider'
plugins-Message: 20:17:23.253: Auto-loading plugin /home/ivanhoe/src/pidgin/build/libpurple/plugins/libsecret/libsecret.so

plugins-Message: 20:17:23.253: Loaded plugin /home/ivanhoe/src/pidgin/build/libpurple/plugins/libsecret/libsecret.so

plugins-Message: 20:17:23.253: Auto-loading plugin /home/ivanhoe/src/pidgin/build/protocols/ircv3/libircv3.so

plugins-Message: 20:17:23.253: Loaded plugin /home/ivanhoe/src/pidgin/build/protocols/ircv3/libircv3.so

plugins-Message: 20:17:23.253: Auto-loading plugin /home/ivanhoe/src/pidgin/build/protocols/xmpp/libxmpp.so

plugins-Message: 20:17:23.253: Loaded plugin /home/ivanhoe/src/pidgin/build/protocols/xmpp/libxmpp.so

plugins-Message: 20:17:23.253: Auto-loading plugin /home/ivanhoe/src/pidgin/build/protocols/demo/libdemo.so

plugins-Message: 20:17:23.253: Loaded plugin /home/ivanhoe/src/pidgin/build/protocols/demo/libdemo.so

plugins-Message: 20:17:23.253: Auto-loading plugin /home/ivanhoe/src/pidgin/build/protocols/bonjour/libbonjournouveau.so

plugins-Message: 20:17:23.253: Loaded plugin /home/ivanhoe/src/pidgin/build/protocols/bonjour/libbonjournouveau.so

plugins-Message: 20:17:23.276: Auto-loading plugin /home/ivanhoe/src/pidgin/build/share/pidgin3/plugins/purple-spasm.so

plugins-Message: 20:17:23.276: Loaded plugin /home/ivanhoe/src/pidgin/build/share/pidgin3/plugins/purple-spasm.so

[New Thread 0x7fffe9ac46c0 (LWP 29427)]
[New Thread 0x7fffe8bff6c0 (LWP 29428)]
[New Thread 0x7fffccbff6c0 (LWP 29429)]
[New Thread 0x7fffbedff6c0 (LWP 29430)]
[New Thread 0x7fffcffff6c0 (LWP 29431)]
[New Thread 0x7fffcf7fe6c0 (LWP 29432)]
[New Thread 0x7fffceffd6c0 (LWP 29433)]
[New Thread 0x7fffce7fc6c0 (LWP 29434)]
PurpleAccountManager-Message: 20:17:23.457: loaded 0 accounts
[New Thread 0x7fffbe5fe6c0 (LWP 29436)]
[New Thread 0x7fffbddfd6c0 (LWP 29437)]
[New Thread 0x7fffbd5fc6c0 (LWP 29438)]
connection-Message: 20:17:35.079: Connecting. connection = 0x55555666d090
connection-Message: 20:17:35.083: Connecting. connection = 0x55555721e490
[New Thread 0x7fff973ff6c0 (LWP 29442)]
[Thread 0x7fffce7fc6c0 (LWP 29434) exited]
[Thread 0x7fffcf7fe6c0 (LWP 29432) exited]
[Thread 0x7fffe9ac46c0 (LWP 29427) exited]
[Thread 0x7fffeaf366c0 (LWP 29425) exited]
account-Message: 20:17:47.555: Disconnecting account iv4nhoe (0x5555565f8a00)

connection-Message: 20:17:47.555: Disconnecting connection 0x55555721e490
connection-Message: 20:17:47.555: Destroying connection 0x55555721e490

(pidgin3:29417): PurpleContactManager-CRITICAL **: 20:17:47.557: purple_contact_manager_remove: assertion 'PURPLE_IS_CONTACT(contact)' failed

(pidgin3:29417): PurpleContactManager-CRITICAL **: 20:17:47.557: purple_contact_manager_remove: assertion 'PURPLE_IS_CONTACT(contact)' failed

(pidgin3:29417): PurpleContactManager-CRITICAL **: 20:17:47.557: purple_contact_manager_remove: assertion 'PURPLE_IS_CONTACT(contact)' failed

(pidgin3:29417): PurpleContactManager-CRITICAL **: 20:17:47.557: purple_contact_manager_remove: assertion 'PURPLE_IS_CONTACT(contact)' failed
connection-Message: 20:17:57.321: Connecting. connection = 0x55555673f1a0
connection-Message: 20:17:57.321: Connecting. connection = 0x55555709bb00

(pidgin3:29417): GLib-GObject-CRITICAL **: 20:17:57.321: invalid uninstantiatable type 'GType' in cast to 'PurpleConnection'

(pidgin3:29417): Purple-CRITICAL **: 20:17:57.321: purple_connection_get_account: assertion 'PURPLE_IS_CONNECTION(connection)' failed

(pidgin3:29417): Purple-CRITICAL **: 20:17:57.321: purple_account_disconnect_with_error: assertion 'PURPLE_IS_ACCOUNT(account)' failed
account-Message: 20:17:57.321: Disconnecting account iv4nhoe (0x5555565c6480)

connection-Message: 20:17:57.321: Disconnecting connection 0x55555709bb00
connection-Message: 20:17:57.321: Destroying connection 0x55555709bb00

(pidgin3:29417): GLib-GIO-CRITICAL **: 20:18:03.169: g_list_model_get_n_items: assertion 'G_IS_LIST_MODEL (list)' failed

I think now I’ve got it:

  • start with a clean build
  • start pidgin and create a demo protocol account with account name and username iv4nhoe
  • realise you didn’t want to create a demo account and remove it again
  • create a spasm account with account name and username iv4nhoe
  • see that it didn’t connect and remove the account again