Bug 57325 - lock mutex before trying to unlock it
Summary: lock mutex before trying to unlock it
Status: RESOLVED FIXED
Alias: None
Product: PolicyKit
Classification: Unclassified
Component: daemon (show other bugs)
Version: unspecified
Hardware: All OpenBSD
: medium major
Assignee: David Zeuthen (not reading bugmail)
QA Contact: David Zeuthen (not reading bugmail)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-20 14:21 UTC by Antoine Jacoutot
Modified: 2013-01-09 19:35 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

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.