After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 665067 - cryptic assertion failure if nonsensical flag combinations are used
cryptic assertion failure if nonsensical flag combinations are used
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
2.31.x
Other Linux
: Normal minor
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-11-28 17:41 UTC by Simon McVittie
Modified: 2011-12-05 18:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GDBusConnection: propagate error correctly if flags are inappropriate (1.26 KB, patch)
2011-11-28 17:55 UTC, Simon McVittie
accepted-commit_now Details | Review

Description Simon McVittie 2011-11-28 17:41:27 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.
Comment 1 Simon McVittie 2011-11-28 17:55:29 UTC
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 2 David Zeuthen (not reading bugmail) 2011-11-28 20:42:16 UTC
Comment on attachment 202308 [details] [review]
GDBusConnection: propagate error correctly if flags are inappropriate

Looks good to me. Thanks.
Comment 3 Simon McVittie 2011-12-05 18:55:50 UTC
Thanks, fixed in git for 2.30.3 (44a1663aa), 2.31.3 (83d0c8a73).