locking bug in glib:g_main_context_iterate()
- From: Matthias Drochner <M Drochner fz-juelich de>
- To: gtk-devel-list gnome org
- Subject: locking bug in glib:g_main_context_iterate()
- Date: Wed, 10 Jan 2007 19:17:53 +0100
Hi -
in g_main_context_iterate(), the function can be left with the
context unlocked in some cases. This leads to double unlocking
of mutexes which might lead to diagnostic printouts or program
aborts, depending on the thread library.
The appended patch fixes it for me. (It only considers the
G_THREADS_ENABLED case; one might rearrange things slightly
for sanity.)
best regards
Matthias
$NetBSD: patch-ai,v 1.13 2007/01/10 14:57:33 drochner Exp $
--- glib/gmain.c.orig 2007-01-10 14:36:51.000000000 +0100
+++ glib/gmain.c
@@ -2619,13 +2619,13 @@ g_main_context_iterate (GMainContext *co
{
gboolean got_ownership;
+ LOCK_CONTEXT (context);
+
g_return_val_if_fail (g_thread_supported (), FALSE);
if (!block)
return FALSE;
- LOCK_CONTEXT (context);
-
if (!context->cond)
context->cond = g_cond_new ();
@@ -2635,7 +2635,6 @@ g_main_context_iterate (GMainContext *co
if (!got_ownership)
{
- UNLOCK_CONTEXT (context);
return FALSE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]