Bug 65130

Summary: Race condition in GObject interface type registration
Product: PolicyKit Reporter: Tomas Bzatek <bugs>
Component: libpolkitAssignee: David Zeuthen (not reading bugmail) <zeuthen>
Status: RESOLVED FIXED QA Contact: David Zeuthen (not reading bugmail) <zeuthen>
Severity: major    
Priority: medium CC: walters
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: [PATCH] Use GOnce for interface type registration

Description Tomas Bzatek 2013-05-29 13:58:38 UTC
Created attachment 79966 [details]
[PATCH] Use GOnce for interface type registration

In certain cases, randomly, udisksd was failing with the following messages:

> (udisksd:10020): GLib-GObject-WARNING **: cannot register existing type `PolkitSubject'
> (udisksd:10020): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
> (udisksd:10020): GLib-GObject-WARNING **: invalid cast from `PolkitSystemBusName' to `<invalid>'
> (udisksd:10020): GLib-GObject-WARNING **: cannot register existing type `PolkitSubject'
> (udisksd:10020): GLib-GObject-WARNING **: cannot register existing type `PolkitSubject'
> (udisksd:10020): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
> (udisksd:10020): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
> ** (udisksd:10020): CRITICAL **: polkit_authority_check_authorization_sync: assertion `POLKIT_IS_SUBJECT (subject)' failed
> ** (udisksd:10020): CRITICAL **: polkit_authority_check_authorization_sync: assertion `POLKIT_IS_SUBJECT (subject)' failed

Further debugging showed missing locking in polkit_subject_get_type() and potential race explaining the first GObject warning.

The attached patch makes the type registration use modern conventions with GOnce.
Comment 1 Colin Walters 2013-05-29 14:14:34 UTC
Looks good.  I amended the patch to include a link back to this bug.

http://cgit.freedesktop.org/polkit/commit/?id=20ad116a6582e57d20f9d8197758947918753a4c
Comment 2 Hans de Goede 2013-05-29 14:34:40 UTC
I can confirm that this patch fixes my reproducable udisksd crashes.
Comment 3 David Zeuthen (not reading bugmail) 2013-05-29 19:23:34 UTC
Nice catch guys, thanks for fixing this!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.