From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Dion via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" Newsgroups: gmane.lisp.guile.bugs Subject: bug#61058: [PATCH] Fix asymetric mutex locking when joining thread. Date: Wed, 25 Jan 2023 10:24:03 -0500 Message-ID: <20230125152403.19091-1-olivier.dion@polymtl.ca> Reply-To: Olivier Dion Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15234"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Olivier Dion To: 61058@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Wed Jan 25 16:25:22 2023 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKheM-0003lT-25 for guile-bugs@m.gmane-mx.org; Wed, 25 Jan 2023 16:25:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKhe3-0002sO-Nr; Wed, 25 Jan 2023 10:25:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKhe2-0002sF-Lc for bug-guile@gnu.org; Wed, 25 Jan 2023 10:25:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKhe2-000209-D6 for bug-guile@gnu.org; Wed, 25 Jan 2023 10:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pKhe2-0005L0-8N for bug-guile@gnu.org; Wed, 25 Jan 2023 10:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Olivier Dion Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 25 Jan 2023 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61058 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167466026620460 (code B ref -1); Wed, 25 Jan 2023 15:25:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Jan 2023 15:24:26 +0000 Original-Received: from localhost ([127.0.0.1]:59746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKhdS-0005Jw-9j for submit@debbugs.gnu.org; Wed, 25 Jan 2023 10:24:26 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:37778) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKhdP-0005Jn-F5 for submit@debbugs.gnu.org; Wed, 25 Jan 2023 10:24:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKhdP-0002dS-4c for bug-guile@gnu.org; Wed, 25 Jan 2023 10:24:23 -0500 Original-Received: from smtp.polymtl.ca ([132.207.4.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKhdN-0001uB-AL for bug-guile@gnu.org; Wed, 25 Jan 2023 10:24:22 -0500 Original-Received: from laura.hitronhub.home (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 30PFO5PX010501 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 25 Jan 2023 10:24:13 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 30PFO5PX010501 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1674660253; bh=a/6GKZx5jbVAr7is9eGijC9lvf/MdFcCrlfMf5SQdnU=; h=From:To:Cc:Subject:Date:From; b=ldg+eXddRyMkq7QjjABwHZ704cK4Ujck5zheVacaDe3KJIHfUiv6xjFKpNb4YV8qW w2IdiKLwhS6tlZo0VM/GGmy6JaVb/TZyOJ6qhMr7OrbS8JJmBFMmdQ7C8pXW83Hzmx B2PD23R76hRuITtav6hoVdUfzOCHYlRZqZfVEnAQ= X-Mailer: git-send-email 2.39.1 X-Poly-FromMTA: (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) at Wed, 25 Jan 2023 15:24:05 +0000 Received-SPF: pass client-ip=132.207.4.11; envelope-from=olivier.dion@polymtl.ca; helo=smtp.polymtl.ca X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.bugs:10537 Archived-At: From: Olivier Dion 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