GNU bug report logs - #61058
[PATCH] Fix asymetric mutex locking when joining thread.

Previous Next

Package: guile;

Reported by: Olivier Dion <olivier.dion <at> polymtl.ca>

Date: Wed, 25 Jan 2023 15:25:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#61058: closed ([PATCH] Fix asymetric mutex locking when
 joining thread.)
Date: Thu, 25 Jan 2024 22:15:03 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 25 Jan 2024 23:14:26 +0100
with message-id <87fryloybh.fsf <at> gnu.org>
and subject line Re: bug#61058: [PATCH v2] Fix asymetric mutex locking when joining thread.
has caused the debbugs.gnu.org bug report #61058,
regarding [PATCH] Fix asymetric mutex locking when joining thread.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
61058: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61058
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Olivier Dion <olivier.dion <at> polymtl.ca>
To: bug-guile <at> gnu.org
Cc: Olivier Dion <olivier-dion <at> proton.me>
Subject: [PATCH] Fix asymetric mutex locking when joining thread.
Date: Wed, 25 Jan 2023 10:24:03 -0500
From: Olivier Dion <olivier-dion <at> proton.me>

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



[Message part 3 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: Olivier Dion <olivier.dion <at> polymtl.ca>
Cc: 55356-done <at> debbugs.gnu.org, 61058-done <at> debbugs.gnu.org
Subject: Re: bug#61058: [PATCH v2] Fix asymetric mutex locking when joining
 thread.
Date: Thu, 25 Jan 2024 23:14:26 +0100
Hello,

Olivier Dion <olivier.dion <at> polymtl.ca> 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’.


This bug report was last modified 1 year and 114 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.