GNU bug report logs - #56728
[PATCH] guile-fibers: Backport the ‘epoll instance is dead’ bugfix.

Previous Next

Package: guix-patches;

Reported by: Maxime Devos <maximedevos <at> telenet.be>

Date: Sat, 23 Jul 2022 19:09:02 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 56728 in the body.
You can then email your comments to 56728 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#56728; Package guix-patches. (Sat, 23 Jul 2022 19:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxime Devos <maximedevos <at> telenet.be>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 23 Jul 2022 19:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: guix-patches <at> gnu.org
Cc: Maxime Devos <maximedevos <at> telenet.be>
Subject: [PATCH] guile-fibers: Backport the ‘epoll instance is dead’ bugfix.
Date: Sat, 23 Jul 2022 21:08:23 +0200
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 <maximedevos <at> telenet.be>
+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
+<https://github.com/wingo/fibers/issues/61>.
+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 <wingo <at> pobox.com>
++;;;; Copyright (C) 2022 Maxime Devos <maximedevos <at> telenet.be>
+ ;;;; 
+ ;;;; 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 <maximedevos <at> telenet.be>
+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 <maximedevos <at> telenet.be>
+ ;;;;
+ ;;;; 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 <https://github.com/wingo/fibers/issues/61>.
++(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





Reply sent to Mathieu Othacehe <othacehe <at> gnu.org>:
You have taken responsibility. (Mon, 15 Aug 2022 13:53:02 GMT) Full text and rfc822 format available.

Notification sent to Maxime Devos <maximedevos <at> telenet.be>:
bug acknowledged by developer. (Mon, 15 Aug 2022 13:53:02 GMT) Full text and rfc822 format available.

Message #10 received at 56728-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 56728-done <at> debbugs.gnu.org
Subject: Re: bug#56728: [PATCH] guile-fibers: Backport the
 ‘epoll instance
 is dead’ bugfix.
Date: Mon, 15 Aug 2022 15:52:18 +0200
> * 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.

Pushed, thanks,

Mathieu




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 13 Sep 2022 11:24:06 GMT) Full text and rfc822 format available.

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

Previous Next


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