GNOME Bugzilla – Bug 665067
cryptic assertion failure if nonsensical flag combinations are used
Last modified: 2011-12-05 18:55:50 UTC
(Noticed while debugging something else.) If you instantiate a GDBusConnection with a specific address, and ask it to perform authentication as a server or allow anonymous auth: conn = g_dbus_connection_new_for_address_sync ("badger:mushroom=snake", G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER, NULL, NULL, &error); it hits this assertion failure: GLib-GIO:ERROR:/tmp/buildd/glib2.0-2.30.2/./gio/gdbusconnection.c:2607:initable_init: assertion failed: (connection->initialization_error != NULL) due to a mistake in error handling (it should have set connection->initialization_error, not *error). Strictly speaking, this should be a g_return_if_fail or a g_critical or something (it's programmer error), but that's harder to do because we're under a lock. The other possibility would be to turn it into an assertion, or a pair of assertions: g_assert ((connection->flags & G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER) == 0); g_assert ((connection->flags & G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS) == 0); Arguably, the following assertions should be a g_critical or a g_return_if_fail too: g_assert (connection->stream == NULL) if address != NULL g_assert_not_reached () if address == NULL, stream == NULL all assertions about flags all assertions about guid but, again, that's hard to do here.
Created attachment 202308 [details] [review] GDBusConnection: propagate error correctly if flags are inappropriate Previously, this would fail the assertion "connection->initialization_error != NULL" after the label "out".
Comment on attachment 202308 [details] [review] GDBusConnection: propagate error correctly if flags are inappropriate Looks good to me. Thanks.
Thanks, fixed in git for 2.30.3 (44a1663aa), 2.31.3 (83d0c8a73).