From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8MoLL2xH3GKtvAAAbAwnHQ (envelope-from ) for ; Sat, 23 Jul 2022 21:09:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0U3uLmxH3GKzfgEA9RJhRA (envelope-from ) for ; Sat, 23 Jul 2022 21:09:32 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6F5313C9FE for ; Sat, 23 Jul 2022 21:09:32 +0200 (CEST) Received: from localhost ([::1]:39532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFKVH-0001SW-Lb for larch@yhetil.org; Sat, 23 Jul 2022 15:09:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFKUp-0001SN-1v for guix-patches@gnu.org; Sat, 23 Jul 2022 15:09:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oFKUo-0002u2-PN for guix-patches@gnu.org; Sat, 23 Jul 2022 15:09:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oFKUo-00087I-JO for guix-patches@gnu.org; Sat, 23 Jul 2022 15:09:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56728] [PATCH] guile-fibers: Backport the =?UTF-8?Q?=E2=80=98epoll?= instance is =?UTF-8?Q?dead=E2=80=99?= bugfix. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 23 Jul 2022 19:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56728 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56728@debbugs.gnu.org Cc: Maxime Devos X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165860331531146 (code B ref -1); Sat, 23 Jul 2022 19:09:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jul 2022 19:08:35 +0000 Received: from localhost ([127.0.0.1]:46308 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFKUM-00086I-OF for submit@debbugs.gnu.org; Sat, 23 Jul 2022 15:08:35 -0400 Received: from lists.gnu.org ([209.51.188.17]:55058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFKUK-000868-EJ for submit@debbugs.gnu.org; Sat, 23 Jul 2022 15:08:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFKUK-0001No-9f for guix-patches@gnu.org; Sat, 23 Jul 2022 15:08:32 -0400 Received: from xavier.telenet-ops.be ([2a02:1800:120:4::f00:14]:49166) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oFKUH-0002rS-EQ for guix-patches@gnu.org; Sat, 23 Jul 2022 15:08:32 -0400 Received: from localhost.localdomain ([IPv6:2a02:1811:8c09:9d00:5dba:d409:33f7:a16]) by xavier.telenet-ops.be with bizsmtp id yj8Q2700920ykKC01j8RRL; Sat, 23 Jul 2022 21:08:25 +0200 From: Maxime Devos Date: Sat, 23 Jul 2022 21:08:23 +0200 Message-Id: <20220723190823.8553-1-maximedevos@telenet.be> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22; t=1658603305; bh=cngd433NvasBbz4LB7PKs1sJAxMZJlE8caQ4kYW0RYE=; h=From:To:Cc:Subject:Date; b=asI8GqGRFkJ+0uP/QWnnXmbYkL/QRB1RN8dKrHm4PKFMbsZI1Y6H64LUAm7+HmMnL L79/26Rg92QG5cjGE+hoGUyEDp6L3BV9mIcBMSbh1VDKnLAs0IbeVXkTufUMgFAzDR Y7veG4XwakGKe41FKEM55Q0vsHetGYqJwcjvw5Ckfu4fw7FKvKM0enc9lEVHj4LxPv VI1SZWtHM1/Dw17i7CB1TAERqM+u+LjbXyC0Uynodgs/G/TrFiKvB/GkkQeW/6YRMF S0lcGIIRv5BW3C3s91egDJJk4ZBRpYdHaczda20hP183Al+dFvJ8MKbkzCDjpHtzmh 7Bosr1ey/AERg== Received-SPF: pass client-ip=2a02:1800:120:4::f00:14; envelope-from=maximedevos@telenet.be; helo=xavier.telenet-ops.be 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1658603372; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=cngd433NvasBbz4LB7PKs1sJAxMZJlE8caQ4kYW0RYE=; b=PSGEDJcvyXco8tv1ap+WxNMo2QLciZZKDWP25BFEP2OHudCzgNqLq5Wse/sAbFCh9jtFgG Qrz+YsOjEasOI3NSHT4jrSJF2J5tgUjEzsiLOUMtr8Vz2v8slO2BO352JjWtIr7sG7NVBj 8HQik7u2gLOmS9C7QcwBu9db7QIkJmMxlIc72BQVUnQ3ZM6pzVQAvFfSVfEHn4cFaBMlpJ 5MG4y3J0zUVUAsAaQETmVZMWgmdPjeFaGqLd+2GmD5utDbwtlph+JXdU+LAyNXCizp/9vO GS1eS1PJKAdqbnSU7lDBupH7s4IO3liIuFm9NbqapYG7L8OuHQtFmEBWwywuRg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1658603372; a=rsa-sha256; cv=none; b=V8QgqeZ+CXvL943+NHikxl3GH7iVCzuXTyFa2+Q02y6ofaDD7VT1nzmwJZMlZrFYHpLpRJ hZPPysQPtNooY1jd1cpDxpZnYzsEq1TQfB7DALP2c7Rm7Q+0SUz+k5db2KNU1obwDckD9y xNB5zxf6U0xNLeNU9XmEFBxbNV6qlHE6w6XydH7Q/I81JLFoflIKEgyKqTNNBYCCI1gHNh 06LGPyK0ntYAJn+YY94nDJ7e09d8DddzzG6hslv+RBFIU12N0VUCPM5WjrbTQhurh9r93L h9yZF5uSAdccx5JYOz0KVN8osu2Zb7EPZ3DgUseb5NOhRuMTp9gnH2jXw0+T5A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r22 header.b=asI8GqGR; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.07 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r22 header.b=asI8GqGR; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6F5313C9FE X-Spam-Score: 6.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: HqGAFvIIMaOp This fixes some indeterministic test failures for gnunet-scheme observed while developing gnunet-scheme. The following checks were made: All dependents compile for x86_64: $ ./pre-inst-env guix build shepherd gnunet-scheme guix-build-coordinator nar-herder guix-data-service guile-fibers --system=x86_64-linux Everything except guix-build-coordinator (which depends on the non-cross-compilable sqitch) cross-compile from x86_64 to aarch64-linux-gnu: $ ./pre-inst-env guix build shepherd gnunet-scheme nar-herder guile-fibers --system=x86_64-linux --target=aarch64-linux-gnu I tried testing for reproducibility but the check phase took to long. However, you can compare the hash you get against the hash I got: $ ./pre-inst-env guix hash --serializer=nar $(./pre-inst-env guix build guile-fibers --no-grafts --system=x86_64-linux) 0qsaqx27b6q2s22h7y93417ijpkwl6gc1fhhck8aha6bvmawk5h0 I tried an emulated build for another architecture, but there the tests took overly long. There were no lint warnings for guile-fibers. * gnu/packages/patches/guile-fibers-epoll-instance-is-dead.patch: New patch. * gnu/local.mk (dist_patch_DATA): Register the patch. * gnu/packages/guile-xyz.scm (guile-fibers)[source]{patches}: Use the patch. --- gnu/local.mk | 1 + gnu/packages/guile-xyz.scm | 3 +- .../guile-fibers-epoll-instance-is-dead.patch | 99 +++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/guile-fibers-epoll-instance-is-dead.patch diff --git a/gnu/local.mk b/gnu/local.mk index 412d512775..64776792b2 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1241,6 +1241,7 @@ dist_patch_DATA = \ %D%/packages/patches/guile-ac-d-bus-fix-tests.patch \ %D%/packages/patches/guile-cross-compilation.patch \ %D%/packages/patches/guile-fibers-destroy-peer-schedulers.patch \ + %D%/packages/patches/guile-fibers-epoll-instance-is-dead.patch \ %D%/packages/patches/guile-fibers-wait-for-io-readiness.patch \ %D%/packages/patches/guile-gdbm-ffi-support-gdbm-1.14.patch \ %D%/packages/patches/guile-git-adjust-for-libgit2-1.2.0.patch \ diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm index 2456509b97..59cd8d0096 100644 --- a/gnu/packages/guile-xyz.scm +++ b/gnu/packages/guile-xyz.scm @@ -619,7 +619,8 @@ (define-public guile-fibers-1.1 (base32 "0ll63d7202clapg1k4bilbnlmfa4qvpjnsd7chbkka4kxf5klilc")) (patches - (search-patches "guile-fibers-wait-for-io-readiness.patch")))) + (search-patches "guile-fibers-wait-for-io-readiness.patch" + "guile-fibers-epoll-instance-is-dead.patch")))) (build-system gnu-build-system) (native-inputs (list texinfo pkg-config autoconf automake libtool diff --git a/gnu/packages/patches/guile-fibers-epoll-instance-is-dead.patch b/gnu/packages/patches/guile-fibers-epoll-instance-is-dead.patch new file mode 100644 index 0000000000..ba191f765d --- /dev/null +++ b/gnu/packages/patches/guile-fibers-epoll-instance-is-dead.patch @@ -0,0 +1,99 @@ +From 5db4077e9f5166033637d2af9532ec6144b85646 Mon Sep 17 00:00:00 2001 +From: Maxime Devos +Date: Thu, 30 Jun 2022 14:21:47 +0000 +Subject: [PATCH 1/2] Fix behaviour of 'epoll-wake!' after 'run-fibers'. + +This avoids the "epoll instance is dead" error noticed in +GNUnet-Scheme's test suite, as reported at +. +A test is added in the next commit. + +This patch has been applied upstream, but there hasn't been +a new release yet at time of writing. + +* fibers/epoll.scm (epoll-wake!)[dead]: Instead of throwing an error, +just return #t. +--- + fibers/epoll.scm | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/fibers/epoll.scm b/fibers/epoll.scm +index d26db4d..eb63242 100644 +--- a/fibers/epoll.scm ++++ b/fibers/epoll.scm +@@ -1,6 +1,7 @@ + ;; epoll + + ;;;; Copyright (C) 2016 Andy Wingo ++;;;; Copyright (C) 2022 Maxime Devos + ;;;; + ;;;; This library is free software; you can redistribute it and/or + ;;;; modify it under the terms of the GNU Lesser General Public +@@ -135,7 +136,12 @@ epoll wait (if appropriate)." + ('waiting + (primitive-epoll-wake (fileno (epoll-wake-write-pipe epoll)))) + ('not-waiting #t) +- ('dead (error "epoll instance is dead")))) ++ ;; This can happen if a fiber was waiting on a condition and ++ ;; run-fibers completes before the fiber completes and afterwards ++ ;; the condition is signalled. In that case, we don't have to ++ ;; resurrect the fiber or something, we can just do nothing. ++ ;; (Bug report: https://github.com/wingo/fibers/issues/61) ++ ('dead #t))) + + (define (epoll-default-folder fd events seed) + (acons fd events seed)) + +From c01d3853eb56ea4adacc31f51f6e917f8c0abe1c Mon Sep 17 00:00:00 2001 +From: Maxime Devos +Date: Thu, 30 Jun 2022 14:18:36 +0000 +Subject: [PATCH 2/2] Test for issue #61. + +* tests/conditions.scm: Add a test. +--- + tests/conditions.scm | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/tests/conditions.scm b/tests/conditions.scm +index 505c42a..179605a 100644 +--- a/tests/conditions.scm ++++ b/tests/conditions.scm +@@ -1,6 +1,7 @@ + ;; Fibers: cooperative, event-driven user-space threads. + + ;;;; Copyright (C) 2016 Free Software Foundation, Inc. ++;;;; Copyright (C) 2022 Maxime Devos + ;;;; + ;;;; This library is free software; you can redistribute it and/or + ;;;; modify it under the terms of the GNU Lesser General Public +@@ -21,6 +22,7 @@ + #:use-module (fibers) + #:use-module (fibers conditions) + #:use-module (fibers operations) ++ #:use-module (fibers scheduler) + #:use-module (fibers timers)) + + (define failed? #f) +@@ -78,4 +80,22 @@ + (wait cv) + #t)) + ++;; Make a condition, wait for it inside a fiber, let the fiber abruptly ++;; terminate and signal the condition afterwards. This tests for the bug ++;; noticed at . ++(assert-equal #t ++ (let ((cv (make-condition))) ++ (run-fibers ++ (lambda () ++ (spawn-fiber (lambda () (wait cv))) ++ (yield-current-task)) ; let the other fiber wait forever ++ ;; This test relies on not draining -- this is the default, ++ ;; but let's make this explicit. ++ #:drain? #false ; ++ ;; For simplicity, disable concurrency and preemption. ++ ;; That way, we can use 'yield-current-task' instead of an ++ ;; arbitrary sleep time. ++ #:hz 0 #:parallelism 1) ++ (signal-condition! cv))) ++ + (exit (if failed? 1 0)) base-commit: d519305d83d08058e4def2c4d72fe62102d9599d -- 2.37.0