bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #27450] Fat mutexes not GC'd until their owner dies


From: Ludovic Courtès
Subject: [bug #27450] Fat mutexes not GC'd until their owner dies
Date: Mon, 14 Sep 2009 22:32:48 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.2) Gecko/20090809 IceCat/3.5.2

URL:
  <http://savannah.gnu.org/bugs/?27450>

                 Summary: Fat mutexes not GC'd until their owner dies
                 Project: Guile
            Submitted by: civodul
            Submitted on: Mon 14 Sep 2009 10:32:47 PM GMT
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

Hello,

In 1.9.2 and earlier (pre-libgc), the following snippet demonstrates in a few
seconds that threads aren't GC'd, despite the fact that `(all-threads)' shows
the right number of threads:

#v+
(use-modules (ice-9 threads))

(let loop ()
  (let* ((m (make-mutex))
         (t (begin
              (lock-mutex m)
              (make-thread (lambda args
                             (lock-mutex m)
                             args)))))
    (cancel-thread t)

    (format #t "~A threads~%" (length (all-threads)))

    (loop)))
#v-

This is because threads here are canceled while waiting in `block_self ()'. 
Threads in `block_self ()' are enqueued in the given queue, which is
associated with the fat mutex.  Cancellation does not give them the
opportunity to get removed from the queue, hence the unbounded data
retention.

But the root cause is that mutexes created in this code aren't GC'd, because
they are associated with the calling thread via `t->mutexes'.  One solution
would be to use weak pointers in `t->mutexes'.

Ludo'.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?27450>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]