From e7bebbe3d4bbd9103b8a2e71e62dfbaef9a928ab Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 18 Sep 2020 10:53:52 +0200 Subject: Fix GC race-condition in spawn-builds. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a derivation is GC'd just before calling "spawn-builds", "build-derivations: will throw an exception that will be catched. Then, "update-build-statuses!" will call "derivation-path->output-paths" that will throw another exception because the derivation does not exit. This exception is not handled, causing Cuirass to crash. 2020-09-18T10:41:18 batch of builds (partially) failed: build of `/gnu/store/zrmxzjf025nc89a7vdy5i94zavprc7fs-emacs-guix-0.5.2-2.58a840d.drv' failed (status: 1) Backtrace: In ice-9/boot-9.scm: 1736:10 11 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _) In unknown file: 10 (apply-smob/0 #) In ice-9/boot-9.scm: 718:2 9 (call-with-prompt _ _ #) In ice-9/eval.scm: 619:8 8 (_ #(#(#))) In ice-9/boot-9.scm: 2806:4 7 (save-module-excursion _) 4351:12 6 (_) In cuirass/base.scm: 562:10 5 (spawn-builds # _ #:max-batch-size _) In srfi/srfi-1.scm: 634:9 4 (for-each # ("/gnu/store/zrmxzjf025nc89a7vdy5i94zavprc7fs-emacs-guix-0.5.2-2.58a840d.drv")) In cuirass/base.scm: 474:4 3 (update! "/gnu/store/zrmxzjf025nc89a7vdy5i94zavprc7fs-emacs-guix-0.5.2-2.58a840d.drv") In guix/derivations.scm: 552:17 2 (derivation-path->output-paths "/gnu/store/zrmxzjf025nc89a7vdy5i94zavprc7fs-emacs-guix-0.5.2-2.58a840d.drv") In ice-9/ports.scm: 440:11 1 (call-with-input-file "/gnu/store/zrmxzjf025nc89a7vdy5i94zavprc7fs-emacs-guix-0.5.2-2.58a840d.drv" # #:binary _ …) In unknown file: 0 (open-file "/gnu/store/zrmxzjf025nc89a7vdy5i94zavprc7fs-emacs-guix-0.5.2-2.58a840d.drv" "r" #:encoding #f #:guess-encoding #f) * src/cuirass/base.scm (update-build-statuses!): Catch "derivation-path->output-paths" exceptions and set the build status to "failed". --- src/cuirass/base.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm index ec1b467..bce151a 100644 --- a/src/cuirass/base.scm +++ b/src/cuirass/base.scm @@ -471,14 +471,17 @@ build products." been passed to 'build-derivations' (meaning that we can assume that, if their outputs are invalid, that they failed to build.)" (define (update! drv) - (match (derivation-path->output-paths drv) + (match (false-if-exception + (derivation-path->output-paths drv)) (((_ . outputs) ...) (if (any (cut valid-path? store <>) outputs) (set-build-successful! drv) (db-update-build-status! drv (if (log-file store drv) (build-status failed) - (build-status failed-dependency))))))) + (build-status failed-dependency))))) + (else + (db-update-build-status! drv (build-status failed))))) (for-each update! lst)) -- cgit v1.2.3