Bug 57325

Summary: lock mutex before trying to unlock it
Product: PolicyKit Reporter: Antoine Jacoutot <ajacoutot>
Component: daemonAssignee: David Zeuthen (not reading bugmail) <zeuthen>
Status: RESOLVED FIXED QA Contact: David Zeuthen (not reading bugmail) <zeuthen>
Severity: major    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: OpenBSD   
Whiteboard:
i915 platform: i915 features:

Description Antoine Jacoutot 2012-11-20 14:21:02 UTC
Hi.

polkit-0.108.

In src/polkitbackend/polkitbackendjsauthority.c, rkt_init_mutex gets unlocked at
line 626:
  g_mutex_unlock (&authority->priv->rkt_init_mutex);

However this mutex was not locked before and on system where the default mutex type is PTHREAD_MUTEX_STRICT_NP, polkitd abort().

This is what I am currently using on OpenBSD to make it work:

--- src/polkitbackend/polkitbackendjsauthority.c.orig	Wed Nov 14 18:09:58 2012
+++ src/polkitbackend/polkitbackendjsauthority.c	Tue Nov 20 14:53:11 2012
@@ -615,6 +620,7 @@ polkit_backend_js_authority_constructed (GObject *obje
     }
 
   g_mutex_init (&authority->priv->rkt_init_mutex);
+  g_mutex_lock (&authority->priv->rkt_init_mutex);
   g_cond_init (&authority->priv->rkt_init_cond);
 
   authority->priv->runaway_killer_thread = g_thread_new ("runaway-killer-thread",

Thoughts?
Comment 1 David Zeuthen (not reading bugmail) 2013-01-09 19:35:42 UTC
Yup, we were forgetting to lock the mutex before calling wait() on the condition variable. I've fixed it up so it follows the example in

 http://developer.gnome.org/glib/unstable/glib-Threads.html#GCond

with this commit

 http://cgit.freedesktop.org/polkit/commit/?id=85ae5715fc05579f6c1b5424bb5ebbb183265eae

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.