Fix invalid assertion about mutex ownership in threads.c.
authorLudovic Courtès <ludo@gnu.org>
Mon, 5 Nov 2012 20:43:13 +0000 (21:43 +0100)
committerLudovic Courtès <ludo@gnu.org>
Mon, 5 Nov 2012 20:43:13 +0000 (21:43 +0100)
* libguile/threads.c (do_thread_exit): Don't assert m->owner == t->handle
  since that is not the case when MUTEX was abandoned by T.  Reported by Mark
  Weaver and others.

libguile/threads.c

index e8305b4..a3aee0f 100644 (file)
@@ -696,10 +696,11 @@ do_thread_exit (void *v)
 
          scm_i_pthread_mutex_lock (&m->lock);
 
-         /* Since MUTEX is in `t->mutexes', T must be its owner.  */
-         assert (scm_is_eq (m->owner, t->handle));
-
-         unblock_from_queue (m->waiting);
+         /* Check whether T owns MUTEX.  This is usually the case, unless
+            T abandoned MUTEX; in that case, T is no longer its owner (see
+            `fat_mutex_lock') but MUTEX is still in `t->mutexes'.  */
+         if (scm_is_eq (m->owner, t->handle))
+           unblock_from_queue (m->waiting);
 
          scm_i_pthread_mutex_unlock (&m->lock);
        }