diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2022-05-26 00:14:29 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-05-26 11:41:05 +0200 |
| commit | 98a6642298be6663b9d318b7dea46d1dba275839 (patch) | |
| tree | 2e88f3d44c168bedc301833fff1f8219637d5ce0 | |
| parent | dcb7ce1eb6911f9d503e7cd2bfe380058cee956b (diff) | |
cuirass: Fork inferior processes before creating threads.
Works around <https://issues.guix.gnu.org/55441#12>.
Start from commit bd86bbd300474204878e927f6cd3f0defa1662a5,
'open-inferior' uses 'primitive-fork' instead of 'open-pipe*'. As a
result, child process could potentially hang before calling 'execl' due
to undefined behavior when forking a multi-threaded process.
* build-aux/cuirass/evaluate.scm <top level>: Call 'open-inferior'
before 'n-par-for-each'.
| -rw-r--r-- | build-aux/cuirass/evaluate.scm | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/build-aux/cuirass/evaluate.scm b/build-aux/cuirass/evaluate.scm index 0bd9e2481f5..5beac1b37c6 100644 --- a/build-aux/cuirass/evaluate.scm +++ b/build-aux/cuirass/evaluate.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2016-2018, 2020, 2022 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org> | 3 | ;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org> |
| 4 | ;;; Copyright © 2021 Mathieu Othacehe <othacehe@gnu.org> | 4 | ;;; Copyright © 2021 Mathieu Othacehe <othacehe@gnu.org> |
| 5 | ;;; | 5 | ;;; |
| @@ -78,29 +78,34 @@ | |||
| 78 | ;; up the evaluation speed as the evaluations can be performed | 78 | ;; up the evaluation speed as the evaluations can be performed |
| 79 | ;; concurrently. It also decreases the amount of memory needed per | 79 | ;; concurrently. It also decreases the amount of memory needed per |
| 80 | ;; evaluation process. | 80 | ;; evaluation process. |
| 81 | (n-par-for-each | 81 | ;; |
| 82 | (/ (current-processor-count) 2) | 82 | ;; Fork inferior processes upfront before we have created any |
| 83 | (lambda (system) | 83 | ;; threads. |
| 84 | (with-store store | 84 | (let ((inferiors (map (lambda _ |
| 85 | (let ((inferior | 85 | (open-inferior (derivation->output-path derivation))) |
| 86 | (open-inferior (derivation->output-path derivation))) | 86 | %cuirass-supported-systems))) |
| 87 | (channels (map channel-instance->sexp instances))) | 87 | (n-par-for-each |
| 88 | (inferior-eval '(use-modules (gnu ci)) inferior) | 88 | (/ (current-processor-count) 2) |
| 89 | (let ((jobs | 89 | (lambda (system inferior) |
| 90 | (inferior-eval-with-store | 90 | (with-store store |
| 91 | inferior store | 91 | (let ((channels (map channel-instance->sexp instances))) |
| 92 | `(lambda (store) | 92 | (inferior-eval '(use-modules (gnu ci)) inferior) |
| 93 | (cuirass-jobs store | 93 | (let ((jobs |
| 94 | '((subset . all) | 94 | (inferior-eval-with-store |
| 95 | (systems . ,(list system)) | 95 | inferior store |
| 96 | (channels . ,channels)))))) | 96 | `(lambda (store) |
| 97 | (file | 97 | (cuirass-jobs store |
| 98 | (string-append directory "/jobs-" system ".scm"))) | 98 | '((subset . all) |
| 99 | (close-inferior inferior) | 99 | (systems . ,(list system)) |
| 100 | (call-with-output-file file | 100 | (channels . ,channels)))))) |
| 101 | (lambda (port) | 101 | (file |
| 102 | (write jobs port))))))) | 102 | (string-append directory "/jobs-" system ".scm"))) |
| 103 | %cuirass-supported-systems)))))) | 103 | (close-inferior inferior) |
| 104 | (call-with-output-file file | ||
| 105 | (lambda (port) | ||
| 106 | (write jobs port))))))) | ||
| 107 | %cuirass-supported-systems | ||
| 108 | inferiors))))))) | ||
| 104 | (x | 109 | (x |
| 105 | (format (current-error-port) "Wrong command: ~a~%." x) | 110 | (format (current-error-port) "Wrong command: ~a~%." x) |
| 106 | (exit 1))) | 111 | (exit 1))) |
