aboutsummaryrefslogtreecommitdiffstats
path: root/devel/glib20
diff options
context:
space:
mode:
authorjylefort <jylefort@FreeBSD.org>2005-07-21 02:24:51 +0800
committerjylefort <jylefort@FreeBSD.org>2005-07-21 02:24:51 +0800
commit6b9f6d2bf6cd72e5653c17f8dd6770c7a62db2e0 (patch)
treed7707a1e0c13509846749ccfcd10107aef42e286 /devel/glib20
parentde5f8de40e7235c603e4f58d92cef97d9c67a29c (diff)
downloadfreebsd-ports-gnome-6b9f6d2bf6cd72e5653c17f8dd6770c7a62db2e0.tar.gz
freebsd-ports-gnome-6b9f6d2bf6cd72e5653c17f8dd6770c7a62db2e0.tar.zst
freebsd-ports-gnome-6b9f6d2bf6cd72e5653c17f8dd6770c7a62db2e0.zip
Fix memory leaks when G_ERRORCHECK_MUTEXES is used:
http://bugzilla.gnome.org/show_bug.cgi?id=311043
Diffstat (limited to 'devel/glib20')
-rw-r--r--devel/glib20/Makefile1
-rw-r--r--devel/glib20/files/patch-glib_gthread.c28
-rw-r--r--devel/glib20/files/patch-glib_gthreadprivate.h53
-rw-r--r--devel/glib20/files/patch-gthread_thread-impl.c185
4 files changed, 267 insertions, 0 deletions
diff --git a/devel/glib20/Makefile b/devel/glib20/Makefile
index 2f00255c1569..f9a8173b320b 100644
--- a/devel/glib20/Makefile
+++ b/devel/glib20/Makefile
@@ -7,6 +7,7 @@
PORTNAME= glib
PORTVERSION= 2.6.5
+PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_GNOME:S,%SUBDIR%,sources/${PORTNAME}/2.6,} \
ftp://ftp.gtk.org/pub/gtk/v2.6/ \
diff --git a/devel/glib20/files/patch-glib_gthread.c b/devel/glib20/files/patch-glib_gthread.c
new file mode 100644
index 000000000000..1dce08388674
--- /dev/null
+++ b/devel/glib20/files/patch-glib_gthread.c
@@ -0,0 +1,28 @@
+--- glib/gthread.c.orig Mon Mar 14 05:02:07 2005
++++ glib/gthread.c Wed Jul 20 19:44:08 2005
+@@ -42,24 +42,8 @@
+
+ #include "glib.h"
+ #include "gthreadinit.h"
++#include "gthreadprivate.h"
+ #include "galias.h"
+-
+-#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
+-# define g_system_thread_equal_simple(thread1, thread2) \
+- ((thread1).dummy_pointer == (thread2).dummy_pointer)
+-# define g_system_thread_assign(dest, src) \
+- ((dest).dummy_pointer = (src).dummy_pointer)
+-#else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
+-# define g_system_thread_equal_simple(thread1, thread2) \
+- (memcmp (&(thread1), &(thread2), GLIB_SIZEOF_SYSTEM_THREAD) == 0)
+-# define g_system_thread_assign(dest, src) \
+- (memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
+-#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
+-
+-#define g_system_thread_equal(thread1, thread2) \
+- (g_thread_functions_for_glib_use.thread_equal ? \
+- g_thread_functions_for_glib_use.thread_equal (&(thread1), &(thread2)) :\
+- g_system_thread_equal_simple((thread1), (thread2)))
+
+ GQuark
+ g_thread_error_quark (void)
diff --git a/devel/glib20/files/patch-glib_gthreadprivate.h b/devel/glib20/files/patch-glib_gthreadprivate.h
new file mode 100644
index 000000000000..0235c20266e3
--- /dev/null
+++ b/devel/glib20/files/patch-glib_gthreadprivate.h
@@ -0,0 +1,53 @@
+--- glib/gthreadprivate.h.orig Wed Jul 20 19:44:08 2005
++++ glib/gthreadprivate.h Wed Jul 20 19:44:08 2005
+@@ -0,0 +1,50 @@
++/* gthreadprivate.h
++ *
++ * Copyright 1998 Sebastian Wilhelmi; University of Karlsruhe
++ * Owen Taylor
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2 of the License, or (at your option) any later version.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 02111-1307, USA.
++ */
++
++#ifndef __G_THREAD_PRIVATE_H__
++#define __G_THREAD_PRIVATE_H__
++
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++
++G_BEGIN_DECLS
++
++#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
++# define g_system_thread_equal_simple(thread1, thread2) \
++ ((thread1).dummy_pointer == (thread2).dummy_pointer)
++# define g_system_thread_assign(dest, src) \
++ ((dest).dummy_pointer = (src).dummy_pointer)
++#else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
++# define g_system_thread_equal_simple(thread1, thread2) \
++ (memcmp (&(thread1), &(thread2), GLIB_SIZEOF_SYSTEM_THREAD) == 0)
++# define g_system_thread_assign(dest, src) \
++ (memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
++#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
++
++#define g_system_thread_equal(thread1, thread2) \
++ (g_thread_functions_for_glib_use.thread_equal ? \
++ g_thread_functions_for_glib_use.thread_equal (&(thread1), &(thread2)) :\
++ g_system_thread_equal_simple((thread1), (thread2)))
++
++G_END_DECLS
++
++#endif /* __G_THREAD_PRIVATE_H__ */
diff --git a/devel/glib20/files/patch-gthread_thread-impl.c b/devel/glib20/files/patch-gthread_thread-impl.c
new file mode 100644
index 000000000000..5f1b6dcbd7ec
--- /dev/null
+++ b/devel/glib20/files/patch-gthread_thread-impl.c
@@ -0,0 +1,185 @@
+--- gthread/gthread-impl.c.orig Fri Feb 14 16:08:46 2003
++++ gthread/gthread-impl.c Wed Jul 20 19:44:08 2005
+@@ -37,9 +37,11 @@
+
+ #include <glib.h>
+ #include <gthreadinit.h>
++#include "gthreadprivate.h"
+
+ #ifdef G_THREADS_ENABLED
+
++static GSystemThread zero_thread; /* This is initialized to all zero */
+ static gboolean thread_system_already_initialized = FALSE;
+ static gint g_thread_priority_map [G_THREAD_PRIORITY_URGENT + 1];
+
+@@ -76,7 +78,7 @@
+ struct _ErrorCheckInfo
+ {
+ gchar *location;
+- GThread *owner;
++ GSystemThread owner;
+ };
+
+ static GMutex *
+@@ -94,7 +96,9 @@
+ gchar *location)
+ {
+ ErrorCheckInfo *info;
+- GThread *self = g_thread_self ();
++ GSystemThread self;
++
++ g_thread_functions_for_glib_use.thread_self (&self);
+
+ if (magic != G_MUTEX_DEBUG_MAGIC)
+ location = "unknown";
+@@ -116,14 +120,14 @@
+ }
+
+ info = G_MUTEX_DEBUG_INFO (mutex);
+- if (info->owner == self)
++ if (g_system_thread_equal (info->owner, self))
+ g_error ("Trying to recursivly lock a mutex at '%s', "
+ "previously locked at '%s'",
+ location, info->location);
+
+ g_thread_functions_for_glib_use_default.mutex_lock (mutex);
+
+- info->owner = self;
++ g_system_thread_assign (info->owner, self);
+ info->location = location;
+ }
+
+@@ -133,7 +137,9 @@
+ gchar *location)
+ {
+ ErrorCheckInfo *info = G_MUTEX_DEBUG_INFO (mutex);
+- GThread *self = g_thread_self ();
++ GSystemThread self;
++
++ g_thread_functions_for_glib_use.thread_self (&self);
+
+ if (magic != G_MUTEX_DEBUG_MAGIC)
+ location = "unknown";
+@@ -145,7 +151,7 @@
+ return TRUE;
+ }
+
+- if (info->owner == self)
++ if (g_system_thread_equal (info->owner, self))
+ g_error ("Trying to recursivly lock a mutex at '%s', "
+ "previously locked at '%s'",
+ location, info->location);
+@@ -153,7 +159,7 @@
+ if (!g_thread_functions_for_glib_use_default.mutex_trylock (mutex))
+ return FALSE;
+
+- info->owner = self;
++ g_system_thread_assign (info->owner, self);
+ info->location = location;
+
+ return TRUE;
+@@ -165,20 +171,22 @@
+ gchar *location)
+ {
+ ErrorCheckInfo *info = G_MUTEX_DEBUG_INFO (mutex);
+- GThread *self = g_thread_self ();
++ GSystemThread self;
++
++ g_thread_functions_for_glib_use.thread_self (&self);
+
+ if (magic != G_MUTEX_DEBUG_MAGIC)
+ location = "unknown";
+
+- if (!info || info->owner == NULL)
++ if (!info || g_system_thread_equal (info->owner, zero_thread))
+ g_error ("Trying to unlock an unlocked mutex at '%s'", location);
+
+- if (info->owner != self)
++ if (!g_system_thread_equal (info->owner, self))
+ g_warning ("Trying to unlock a mutex at '%s', "
+ "previously locked by a different thread at '%s'",
+ location, info->location);
+
+- info->owner = NULL;
++ g_system_thread_assign (info->owner, zero_thread);
+ info->location = NULL;
+
+ g_thread_functions_for_glib_use_default.mutex_unlock (mutex);
+@@ -194,7 +202,7 @@
+ if (magic != G_MUTEX_DEBUG_MAGIC)
+ location = "unknown";
+
+- if (info && info->owner != NULL)
++ if (info && !g_system_thread_equal (info->owner, zero_thread))
+ g_error ("Trying to free a locked mutex at '%s', "
+ "which was previously locked at '%s'",
+ location, info->location);
+@@ -211,25 +219,27 @@
+ {
+
+ ErrorCheckInfo *info = G_MUTEX_DEBUG_INFO (mutex);
+- GThread *self = g_thread_self ();
++ GSystemThread self;
++
++ g_thread_functions_for_glib_use.thread_self (&self);
+
+ if (magic != G_MUTEX_DEBUG_MAGIC)
+ location = "unknown";
+
+- if (!info || info->owner == NULL)
++ if (!info || g_system_thread_equal (info->owner, zero_thread))
+ g_error ("Trying to use an unlocked mutex in g_cond_wait() at '%s'",
+ location);
+
+- if (info->owner != self)
++ if (!g_system_thread_equal (info->owner, self))
+ g_error ("Trying to use a mutex locked by another thread in "
+ "g_cond_wait() at '%s'", location);
+
+- info->owner = NULL;
++ g_system_thread_assign (info->owner, zero_thread);
+ location = info->location;
+
+ g_thread_functions_for_glib_use_default.cond_wait (cond, mutex);
+
+- info->owner = self;
++ g_system_thread_assign (info->owner, self);
+ info->location = location;
+ }
+
+@@ -242,28 +252,30 @@
+ gchar *location)
+ {
+ ErrorCheckInfo *info = G_MUTEX_DEBUG_INFO (mutex);
+- GThread *self = g_thread_self ();
++ GSystemThread self;
+ gboolean retval;
+
++ g_thread_functions_for_glib_use.thread_self (&self);
++
+ if (magic != G_MUTEX_DEBUG_MAGIC)
+ location = "unknown";
+
+- if (!info || info->owner == NULL)
++ if (!info || g_system_thread_equal (info->owner, zero_thread))
+ g_error ("Trying to use an unlocked mutex in g_cond_timed_wait() at '%s'",
+ location);
+
+- if (info->owner != self)
++ if (!g_system_thread_equal (info->owner, self))
+ g_error ("Trying to use a mutex locked by another thread in "
+ "g_cond_timed_wait() at '%s'", location);
+
+- info->owner = NULL;
++ g_system_thread_assign (info->owner, zero_thread);
+ location = info->location;
+
+ retval = g_thread_functions_for_glib_use_default.cond_timed_wait (cond,
+ mutex,
+ end_time);
+
+- info->owner = self;
++ g_system_thread_assign (info->owner, self);
+ info->location = location;
+
+ return retval;