From b73f7ceff479a96fad9d79ffdbfda346ec0bd567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 16 Dec 2023 11:53:10 +0100 Subject: [PATCH] classify SIGSEV/SIGBUS as infinite recursion errors --- src/nix-eval-jobs.cc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/nix-eval-jobs.cc b/src/nix-eval-jobs.cc index 3c7280d..187c95d 100644 --- a/src/nix-eval-jobs.cc +++ b/src/nix-eval-jobs.cc @@ -126,17 +126,34 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) { if (WEXITSTATUS(status) == 1) { throw Error( "while %s, evaluation worker exited with exit code 1, " - "(possibly an infinite recursion)", + "(possible infinite recursion)", msg); } throw Error("while %s, evaluation worker exited with %d", msg, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { - if (WTERMSIG(status) == SIGKILL) { - throw Error("while %s, evaluation worker got killed by " - "SIGKILL, maybe " - "memory limit reached?", - msg); + switch (WTERMSIG(status)) { + case SIGKILL: + throw Error( + "while %s, evaluation worker got killed by SIGKILL, " + "maybe " + "memory limit reached?", + msg); + break; +#ifdef __APPLE__ + case SIGBUS: + throw Error( + "while %s, evaluation worker got killed by SIGBUS, " + "(possible infinite recursion)", + msg); + break; +#else + case SIGSEGV: + throw Error( + "while %s, evaluation worker got killed by SIGSEGV, " + "(possible infinite recursion)", + msg); +#endif } throw Error( "while %s, evaluation worker got killed by signal %d (%s)",