From: ludo@gnu.org (Ludovic Courtès)
To: Carlo Zancanaro <carlo@zancanaro.id.au>
Cc: 30948@debbugs.gnu.org
Subject: [bug#30948] [PATCH core-updates] guix: Reap finished child processes in build containers.
Date: Thu, 29 Mar 2018 22:07:05 +0200 [thread overview]
Message-ID: <87bmf6ve6u.fsf@gnu.org> (raw)
In-Reply-To: <87muyvulwt.fsf@zancanaro.id.au> (Carlo Zancanaro's message of "Mon, 26 Mar 2018 22:16:34 +1100")
[-- Attachment #1: Type: text/plain, Size: 3231 bytes --]
Hi Carlo,
Carlo Zancanaro <carlo@zancanaro.id.au> skribis:
> When working on the Shepherd, I found that in the build containers
> processes don't get reaped by pid 1. See
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30637#29. This caused
> (and will cause) the Shepherd's tests to fail on some systems.
>
> Our guile-builder script should handle SIGCHLD and then use waitpid to
> reap the child processes. Here's my attempt at a patch to do that.
I would rather install the handler as a phase in gnu-build-system: this
leaves ‘build-expression->derivation’ generic, and also gives us more
flexibility (e.g., we can disable that phase without doing a full
rebuild if needed.) See the patch below.
WDYT?
On my first attempt with:
./pre-inst-env guix build -e '(@@ (gnu packages commencement) findutils-boot0)'
quickly failed:
--8<---------------cut here---------------start------------->8---
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... Backtrace:
In ice-9/boot-9.scm:
yes
checking for working vfork... (cached) yes
checking for strcasecmp... 157: 13 [catch #t #<catch-closure c900a0> ...]
In unknown file:
?: 12 [apply-smob/1 #<catch-closure c900a0>]
In ice-9/boot-9.scm:
63: 11 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
432: 10 [eval # #]
In ice-9/boot-9.scm:
2320: 9 [save-module-excursion #<procedure cc1b80 at ice-9/boot-9.scm:3961:3 ()>]
3966: 8 [#<procedure cc1b80 at ice-9/boot-9.scm:3961:3 ()>]
1645: 7 [%start-stack load-stack #<procedure cbd2c0 at ice-9/boot-9.scm:3957:10 ()>]
1650: 6 [#<procedure cc3060 ()>]
In unknown file:
?: 5 [primitive-load "/gnu/store/pz3jy89ax5jg0j6fnp5n42x4vznga8s3-make-boot0-4.2.1-guile-builder"]
In ice-9/eval.scm:
387: 4 [eval # ()]
In srfi/srfi-1.scm:
619: 3 [for-each #<procedure 1217560 at /gnu/store/hf8xflikhgsd4hfy9h8s0cjzfqm8f3yb-module-import/guix/build/gnu-build-system.scm:815:12 (expr)> ...]
In /gnu/store/hf8xflikhgsd4hfy9h8s0cjzfqm8f3yb-module-import/guix/build/gnu-build-system.scm:
819: 2 [#<procedure 1217560 at /gnu/store/hf8xflikhgsd4hfy9h8s0cjzfqm8f3yb-module-import/guix/build/gnu-build-system.scm:815:12 (expr)> #]
In /gnu/store/hf8xflikhgsd4hfy9h8s0cjzfqm8f3yb-module-import/guix/build/utils.scm:
614: 1 [invoke "/gnu/store/g34swjqyw205d15pyra39j56qvyxq9w9-bootstrap-binaries-0/bin/bash" ...]
In unknown file:
?: 0 [system* "/gnu/store/g34swjqyw205d15pyra39j56qvyxq9w9-bootstrap-binaries-0/bin/bash" ...]
ERROR: In procedure system*:
ERROR: In procedure system*: Interrupted system call
builder for `/gnu/store/hc96d5dcshbdgavpp0j01qnsjf0yf9z5-make-boot0-4.2.1.drv' failed with exit code 1
--8<---------------cut here---------------end--------------->8---
This is why ‘install-SIGCHLD-handler’ in the patch does nothing on Guile
<= 2.0.9.
Now, we’d need to test it for real with Guile 2.2. I suppose one way to
test without rebuilding it all would be to add this phase explicitly in
a package and try building it with --rounds=10 or something. Would you
like to try that?
Note that we have only a couple of days left before the ‘core-updates’
freeze.
Thanks,
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1878 bytes --]
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index be5ad78b9..2c6cb4ad2 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -51,6 +51,28 @@
(define time-monotonic time-tai))
(else #t))
+(define* (install-SIGCHLD-handler #:rest _)
+ "Handle SIGCHLD signals. Since this code is usually running as PID 1 in the
+build daemon, it has to reap dead processes, hence this procedure."
+ ;; In Guile <= 2.0.9, syscalls could throw EINTR. With these versions,
+ ;; installing a SIGCHLD handler is not safe because we could have uncaught
+ ;; 'system-error' exceptions at any time.
+ (when (or (not (string=? (effective-version) "2.0"))
+ (> (string->number (micro-version)) 9))
+ (format #t "installing SIGCHLD handler in PID ~a\n" (getpid))
+ (sigaction SIGCHLD
+ (lambda _
+ (let loop ()
+ (match (catch 'system-error
+ (lambda ()
+ (waitpid WAIT_ANY WNOHANG))
+ (lambda args
+ '(0 . -)))
+ ((0 . _) #f)
+ ((pid . _) (loop)))))
+ SA_NOCLDSTOP))
+ #t)
+
(define* (set-SOURCE-DATE-EPOCH #:rest _)
"Set the 'SOURCE_DATE_EPOCH' environment variable. This is used by tools
that incorporate timestamps as a way to tell them to use a fixed timestamp.
@@ -758,7 +780,8 @@ which cannot be found~%"
;; Standard build phases, as a list of symbol/procedure pairs.
(let-syntax ((phases (syntax-rules ()
((_ p ...) `((p . ,p) ...)))))
- (phases set-SOURCE-DATE-EPOCH set-paths install-locale unpack
+ (phases install-SIGCHLD-handler
+ set-SOURCE-DATE-EPOCH set-paths install-locale unpack
bootstrap
patch-usr-bin-file
patch-source-shebangs configure patch-generated-file-shebangs
next prev parent reply other threads:[~2018-03-29 20:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 11:16 [bug#30948] [PATCH core-updates] guix: Reap finished child processes in build containers Carlo Zancanaro
2018-03-26 23:39 ` Carlo Zancanaro
2018-03-29 20:07 ` Ludovic Courtès [this message]
2018-03-29 21:15 ` Carlo Zancanaro
2018-03-30 8:16 ` Ludovic Courtès
2018-03-30 11:17 ` Carlo Zancanaro
2018-03-30 15:17 ` Ludovic Courtès
2022-11-24 16:40 ` Maxim Cournoyer
2022-11-24 16:44 ` bug#30948: " Maxim Cournoyer
2022-11-26 15:11 ` Ludovic Courtès
2022-11-27 3:00 ` Maxim Cournoyer
2022-11-28 15:04 ` Ludovic Courtès
2022-11-28 20:10 ` Maxim Cournoyer
2022-11-29 2:07 ` Maxim Cournoyer
2023-12-17 20:23 ` bug#30948: [PATCH core-updates] build-system/gnu: Turn PID 1 into an “init”-style process by default Ludovic Courtès
2023-12-17 21:46 ` Maxim Cournoyer
2023-12-18 17:46 ` bug#30948: [PATCH core-updates] guix: Reap finished child processes in build containers Ludovic Courtès
2023-12-30 3:36 ` Maxim Cournoyer
2023-12-19 22:56 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bmf6ve6u.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=30948@debbugs.gnu.org \
--cc=carlo@zancanaro.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.