Subject: bug#61058: closed (Re: bug#61058: [PATCH v2] Fix asymetric mutex locking when joining thread.)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 25 Jan 2024 22:15:03 +0000

Your bug report

#61058: [PATCH] Fix asymetric mutex locking when joining thread.

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
61058: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61058
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#61058: [PATCH v2] Fix asymetric mutex locking when joining thread.
From: Ludovic Courtès <[email-masked]>
To: Olivier Dion <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Thu, 25 Jan 2024 23:14:26 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

Olivier Dion <[email-masked]> skribis:

> If `join-thread' timeout, the thread mutex is not unlocked, resulting in
> deadlock to the next call to it or deadlock of the thread itself when it
> terminates.
>
> Thus, always unlock the mutex.
>
> Fix: #55356
>
> * module/ice-9/threads.scm (join-thread): Always unlock thread mutex.
> * test-suite/tests/threads.test (join-thread): New test to ensure the
> mutex is released

Pushed as 455ee49f5573baa1bc5237a8d49083ce588a13ee with a ‘NEWS’ entry
and an additional comment in the test.

Thanks!

Ludo’.

Subject: [PATCH] Fix asymetric mutex locking when joining thread.
From: Olivier Dion <[email-masked]>
To: [email-masked]
Cc: Olivier Dion <[email-masked]>
Date: Wed, 25 Jan 2023 10:24:03 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

From: Olivier Dion <[email-masked]>

If `join-thread' timeout, the thread mutex is not unlocked,
resulting in deadlock to the next call to it or deadlock of the
thread itself when it terminates.

Thus, always unlock the mutex.

Fix: #55356

* module/ice-9/threads.scm (join-thread): Always unlock thread mutex.
---
 module/ice-9/threads.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/module/ice-9/threads.scm b/module/ice-9/threads.scm
index c42bd266f..962caee70 100644
--- a/module/ice-9/threads.scm
+++ b/module/ice-9/threads.scm
@@ -197,7 +197,9 @@ terminates, unless the target @var{thread} has already terminated."
              (wait-condition-variable cv mutex timeout)
              (wait-condition-variable cv mutex))
          (lp))
-        (else timeoutval))))))
+        (else
+         (unlock-mutex mutex)
+         timeoutval))))))
 
 (define* (try-mutex mutex)
   "Try to lock @var{mutex}.  If the mutex is already locked, return
-- 
2.39.1