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 697698 - Race condition in media keys
Race condition in media keys
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: media-keys
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2013-04-10 10:43 UTC by Lionel Landwerlin
Modified: 2013-04-10 18:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix race condition (2.14 KB, patch)
2013-04-10 10:43 UTC, Lionel Landwerlin
needs-work Details | Review
Fix race condition v2 (1.20 KB, patch)
2013-04-10 11:37 UTC, Lionel Landwerlin
accepted-commit_now Details | Review
Fix race condition v3 (2.03 KB, patch)
2013-04-10 12:37 UTC, Lionel Landwerlin
reviewed Details | Review
Fix race condition v4 (2.37 KB, patch)
2013-04-10 14:10 UTC, Lionel Landwerlin
committed Details | Review

Description Lionel Landwerlin 2013-04-10 10:43:00 UTC
For some reason I see a crash in the settings daemon in the settings_changed_cb() callback when accessing manager->priv->keys->len.
 
It seems that the gsettings callback is called before manager->priv->keys is initialized. And that would happen after because init_kbd() which initialized manager->priv->keys is called upon shell's dbus appearance.
Comment 1 Lionel Landwerlin 2013-04-10 10:43:48 UTC
Created attachment 241132 [details] [review]
Fix race condition
Comment 2 Bastien Nocera 2013-04-10 11:18:20 UTC
Review of attachment 241132 [details] [review]:

::: plugins/media-keys/gsd-media-keys-manager.c
@@ +603,2 @@
         /* Find the key that was modified */
+        if (manager->priv->keys) {

I would bail out of the function if the shell wasn't there yet instead. It makes it clearer what the intent is.
Comment 3 Lionel Landwerlin 2013-04-10 11:37:32 UTC
Created attachment 241135 [details] [review]
Fix race condition v2
Comment 4 Bastien Nocera 2013-04-10 11:59:57 UTC
Review of attachment 241135 [details] [review]:

Can you add a comment above the patch? Something like "Keys not initialised yet?"

Looks good to commit to gnome-3-8 and master.
Comment 5 Lionel Landwerlin 2013-04-10 12:37:22 UTC
Created attachment 241145 [details] [review]
Fix race condition v3

I actually saw another crasher in the same file.
So I reworked a bit the allocation of manager->priv->keys and also left the previous check that is necessary anyway (that function is going to talk to the shell, we need to check that we have a proxy for it).
Comment 6 Bastien Nocera 2013-04-10 13:54:07 UTC
Review of attachment 241145 [details] [review]:

::: plugins/media-keys/gsd-media-keys-manager.c
@@ +770,3 @@
         gnome_settings_profile_start (NULL);
 
+        g_ptr_array_set_size (manager->priv->keys, 0);

Shouldn't we call this when the key-grabbed goes away instead?
Comment 7 Lionel Landwerlin 2013-04-10 14:10:05 UTC
Created attachment 241158 [details] [review]
Fix race condition v4
Comment 8 Bastien Nocera 2013-04-10 14:13:25 UTC
Review of attachment 241158 [details] [review]:

Ace. Please commit to gnome-3-8 and master
Comment 9 Lionel Landwerlin 2013-04-10 18:09:36 UTC
Review of attachment 241158 [details] [review]:

Committed.