From patchwork Sun May 26 03:18:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip McGrath X-Patchwork-Id: 64889 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BA17D27BBEA; Sun, 26 May 2024 04:20:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A2AFF27BBE2 for ; Sun, 26 May 2024 04:20:16 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sB4QO-0006Tk-Dp; Sat, 25 May 2024 23:19:56 -0400 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 1sB4QM-0006T0-Rq for guix-patches@gnu.org; Sat, 25 May 2024 23:19:54 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sB4QM-00010O-GK for guix-patches@gnu.org; Sat, 25 May 2024 23:19:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sB4QU-0008Lq-BA; Sat, 25 May 2024 23:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71203] [PATCH 3/3] gnu: chez-scheme: Backport test fix. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: philip@philipmcgrath.com, guix-patches@gnu.org Resent-Date: Sun, 26 May 2024 03:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71203 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71203@debbugs.gnu.org Cc: Philip McGrath X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Philip McGrath Received: via spool by submit@debbugs.gnu.org id=B.171669354431980 (code B ref -1); Sun, 26 May 2024 03:20:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 May 2024 03:19:04 +0000 Received: from localhost ([127.0.0.1]:38114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sB4PX-0008Jj-Re for submit@debbugs.gnu.org; Sat, 25 May 2024 23:19:04 -0400 Received: from lists.gnu.org ([209.51.188.17]:52488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sB4PT-0008Ip-QU for submit@debbugs.gnu.org; Sat, 25 May 2024 23:19:00 -0400 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 1sB4PL-0006Gq-IL for guix-patches@gnu.org; Sat, 25 May 2024 23:18:51 -0400 Received: from wfout1-smtp.messagingengine.com ([64.147.123.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sB4PJ-0000uL-9i for guix-patches@gnu.org; Sat, 25 May 2024 23:18:51 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 29A271C000D0 for ; Sat, 25 May 2024 23:18:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 25 May 2024 23:18:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1716693527; x=1716779927; bh=4HO8bYsQTpbrS1vsTrxrVwjcZyfq3sNM eAqc78Z1zxU=; b=MG0URkALRhNpjC2iQAeuiY+SqU/xYqb25yWGIsChuigcQ0v/ mKMM/S+LHR7TqNIJ+7kYHrHeFGPrf2m40d62vAHCkFN4K4fWgBMukRTR6iahIk3k OUyCTcZkPNfcrSzMhT1VmROxQ/JNt+X1diwQcA0n/s1skcznFZZPQqj1rnP2Yh9r TKyqwkoWVmwkJT6CcFu0UDurwSRmdvek8+bduecIgzn7bFZ0J2b35GJS1WUliBaT 9uLjojNYbBpqUKo3PVR/2Mi88iIHrWmXXKvV6Y07cEsedwy0dCcpu5jvnlRPWVfD Z7GJK9g4/9MLdMrXF0V6w3l+E34nm0sEqPpfdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1716693527; x=1716779927; bh=4HO8bYsQTpbrS 1vsTrxrVwjcZyfq3sNMeAqc78Z1zxU=; b=JuJ3KyI7iO9fbSB9eXLsSXY+fjcVr /Ibn0KpUjIQ7wirsS1b42/d8MuOpu+8PuZoAgtxD4QhAFMer7ADs0hk8fnIl9J6i /0+Jd2NhZjcc02/T1/xXFZuvbd5I6Kw0c0Z4OrZlDJwCxsSB48AzcRaBZYnzUBIA 5Cz5G1t4cvxe2G8vd7s9xW46K+PDnbwvAZt6G3ujUtBy7H2tzvPUOiZ5Ex2PfWuj 7xcYnIjXsH1c5oakqPJRJ8Y/G4AXGnL3KAo1pBnuHnnUJWxMP8mmq4H560yYtoxS uXt+c8FOBsyVsNd5g1XqaTgHC0W7J1odo0Ji33E1ZKqMpjk3VYj0rbTJA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdejuddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheprfhhihhlihhpucfotgfirhgrthhhuceophhhihhlihhpsehp hhhilhhiphhmtghgrhgrthhhrdgtohhmqeenucggtffrrghtthgvrhhnpedukefhveeile fhkeevgeeghfdvgfevvdefgeeiudfgveevffejteethfelgffftdenucffohhmrghinhep ghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphhhihhlihhpsehphhhilhhiphhmtghgrhgrthhhrdgtohhm X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 25 May 2024 23:18:47 -0400 (EDT) From: Philip McGrath Date: Sat, 25 May 2024 23:18:43 -0400 Message-ID: <3610d2d5d8141d4be1dae8faa1b5ede61e2ff882.1716692931.git.philip@philipmcgrath.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.144; envelope-from=philip@philipmcgrath.com; helo=wfout1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches The backported commit fixes crashes when signals are delivered to non-Scheme threads, including GC worker threads and threads created by foreign libraries. This appears to have been the cause of the intermittent test failures we have experienced. * gnu/packages/patches/chez-scheme-backport-signal.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/chez-scheme.scm (chez-scheme)[source]: Use it. (chez-scheme-for-racket, chez-scheme): Enable tests. Change-Id: Ifd87ca0d1707ef6ad067d883772a5b42803ead94 --- gnu/local.mk | 1 + gnu/packages/chez.scm | 3 +- .../patches/chez-scheme-backport-signal.patch | 87 +++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/chez-scheme-backport-signal.patch diff --git a/gnu/local.mk b/gnu/local.mk index 5136c92bcf..190e4bd27b 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1026,6 +1026,7 @@ dist_patch_DATA = \ %D%/packages/patches/ccextractor-autoconf-tesseract.patch \ %D%/packages/patches/ccextractor-fix-ocr.patch \ %D%/packages/patches/chez-scheme-backport-configure.patch \ + %D%/packages/patches/chez-scheme-backport-signal.patch \ %D%/packages/patches/chez-scheme-bin-sh.patch \ %D%/packages/patches/circos-remove-findbin.patch \ %D%/packages/patches/cdparanoia-fpic.patch \ diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm index dd98966c78..8c52bbb188 100644 --- a/gnu/packages/chez.scm +++ b/gnu/packages/chez.scm @@ -329,8 +329,6 @@ (define-public chez-scheme-for-racket (ice-9 match) (srfi srfi-34)) #:out-of-source? #t - ;; Intermittent failures: https://github.com/cisco/ChezScheme/issues/809 - #:tests? #f #:test-target "test" ; test-one test-some-fast test-some test test-more #:configure-flags #~`(,@(let* ((chez+version (strip-store-file-name #$output)) @@ -509,6 +507,7 @@ (define-public chez-scheme "1q66vafhiwk617z51qkm1v64r3bxqhhf5lzrmsa4l9d5yhvlyk09")) (file-name (git-file-name name version)) (patches (search-patches "chez-scheme-backport-configure.patch" + "chez-scheme-backport-signal.patch" "chez-scheme-bin-sh.patch")) (snippet #~(begin (use-modules (guix build utils)) diff --git a/gnu/packages/patches/chez-scheme-backport-signal.patch b/gnu/packages/patches/chez-scheme-backport-signal.patch new file mode 100644 index 0000000000..1fee32b167 --- /dev/null +++ b/gnu/packages/patches/chez-scheme-backport-signal.patch @@ -0,0 +1,87 @@ +From e416651d8b53fa2eca6edde764a9131d128cd166 Mon Sep 17 00:00:00 2001 +From: Matthew Flatt +Date: Sat, 2 Mar 2024 07:18:41 -0700 +Subject: [PATCH] constrain signal delivery to Scheme to the main thread (#813) + +The intent is to avoid crashes when a signal gets delimited to a +thread that might not even be a Scheme thread. Also, we don't try to +queue the event directly in the main thread's context, because then +we'd need more of a lock (while signal handling is otherwise an +implicit lock). + +(cherry picked from commit fc081fc447a786dd53286e5d7314b7217631cb68) +--- + +Notes: + This should fix intermittent test failures experienced by Guix: + see . + + c/globals.h | 1 + + c/schsig.c | 10 ++++++++++ + c/thread.c | 1 + + csug/system.stex | 2 ++ + 4 files changed, 14 insertions(+) + +diff --git a/c/globals.h b/c/globals.h +index d2a08299..eb2965c5 100644 +--- a/c/globals.h ++++ b/c/globals.h +@@ -49,6 +49,7 @@ EXTERN int S_num_preserve_ownership_threads; + # ifdef IMPLICIT_ATOMIC_AS_EXPLICIT + EXTERN s_thread_mutex_t S_implicit_mutex; + # endif ++EXTERN s_thread_t S_main_thread_id; + #endif + + /* segment.c */ +diff --git a/c/schsig.c b/c/schsig.c +index a89ab62a..04677730 100644 +--- a/c/schsig.c ++++ b/c/schsig.c +@@ -666,6 +666,16 @@ ptr S_dequeue_scheme_signals(ptr tc) { + static void forward_signal_to_scheme(INT sig) { + ptr tc = get_thread_context(); + ++#ifdef PTHREADS ++ /* deliver signals to the main thread, only; depending ++ on the threads that are running, `tc` might even be NULL */ ++ if (tc != TO_PTR(&S_G.thread_context)) { ++ pthread_kill(S_main_thread_id, sig); ++ RESET_SIGNAL ++ return; ++ } ++#endif ++ + if (enqueue_scheme_signal(tc, sig)) { + SIGNALINTERRUPTPENDING(tc) = Strue; + SOMETHINGPENDING(tc) = Strue; +diff --git a/c/thread.c b/c/thread.c +index 9a341b22..f130f44d 100644 +--- a/c/thread.c ++++ b/c/thread.c +@@ -40,6 +40,7 @@ void S_thread_init(void) { + s_thread_cond_init(&S_terminated_cond); + S_alloc_mutex.owner = 0; + S_alloc_mutex.count = 0; ++ S_main_thread_id = s_thread_self(); + + # ifdef IMPLICIT_ATOMIC_AS_EXPLICIT + s_thread_mutex_init(&S_implicit_mutex); +diff --git a/csug/system.stex b/csug/system.stex +index d4f2bcbb..bb89f419 100644 +--- a/csug/system.stex ++++ b/csug/system.stex +@@ -547,6 +547,8 @@ After a signal handler for a given signal has been registered, receipt + of the specified signal results in a call to the handler. + The handler is passed the signal number, allowing the same handler to + be used for different signals while differentiating among them. ++In a threaded version of the system, signals are always delivered to ++the main thread. + + Signals handled in this fashion are treated like keyboard interrupts in + that the handler is not called immediately when the signal is delivered + +base-commit: 253230f7dfbb4fe777277d6bbf93f39f9567f086 +-- +2.41.0 +