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 652025 - g_dbus_connection_register_object: error is not set when !g_variant_is_object_path(object_path)
g_dbus_connection_register_object: error is not set when !g_variant_is_object...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other Linux
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-06-07 07:55 UTC by Yasushi SHOJI
Modified: 2011-06-09 06:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test code for invalid application id (400 bytes, text/plain)
2011-06-07 07:55 UTC, Yasushi SHOJI
Details

Description Yasushi SHOJI 2011-06-07 07:55:56 UTC
Created attachment 189376 [details]
test code for invalid application id

this bug can easily be re-produced with invalid application_id to g_application_new() and call g_application_run().

from the code path from g_application_run(), it goes down to the g_dbus_connection_register_object() and checks to see the given object_path is actually a valid "object path" with g_variant_is_object_path() in g_return_val_if_fail macro at the very beginning of the function.  if the given object_path is not valid, meaning having "-" for example, it will return to g_application_impl_register(), g_application_register(), and reach back to g_application_real_local_command_line().

in the g_application_real_local_command_line(), when g_application_register() returns false, the code assumes that the passed variable "error" is set, however, this is not the case in this code pass.

what would be the best idiom to use in this case?
Comment 1 Allison Karlitskaya (desrt) 2011-06-09 02:18:26 UTC
I think we should accept '-' and use it as a bus name (since that is allowed) but when creating the corresponding object path, change any '-' to '_'.

This creates a contradiction.  If someone tries to put 'org.dumb-example' and 'org.dumb_example' in the same process the API suggests that it should theoretically work, but it will actually fail.

We could fix that by banning '_' in application IDs, and we'd have good reason to: it's not valid DNS.
Comment 2 Allison Karlitskaya (desrt) 2011-06-09 02:23:01 UTC
commit f44cd4129356dd569fd90e3ea83e386bce0602a7
Author: Ryan Lortie <desrt@desrt.ca>
Date:   Wed Jun 8 22:21:15 2011 -0400

    GApplication: allow '-' in application ID
    
    By converting it to _ before trying to shove it into an object path.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=652025
Comment 3 Allison Karlitskaya (desrt) 2011-06-09 04:44:50 UTC
btw: about the reported problem that a GError isn't returned in the error case: it is commonly true that hitting a g_critical will result in an unset GError.  There are many many examples of this in GLib, and I don't think we could (or should) fix them all.
Comment 4 Yasushi SHOJI 2011-06-09 06:12:33 UTC
ah, ok.

g_return_val_if_fail() indicates a programming error, and that means you never know what will happen after that, right?

understood. and appreciate for your clarification and the fix.

Thanks,