forked from lix-project/nix-eval-jobs
Merge pull request #289 from nix-community/joerg-ci
fix exit status reporting when evaluation fails
This commit is contained in:
commit
4a1123c42d
|
@ -113,29 +113,47 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
|
||||||
int rc = waitpid(pid, &status, WNOHANG);
|
int rc = waitpid(pid, &status, WNOHANG);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
throw Error(
|
throw Error("BUG: while %s, worker pipe got closed but evaluation "
|
||||||
"BUG: while %s, worker pipe got closed but evaluation worker still running?",
|
"worker still running?",
|
||||||
msg);
|
msg);
|
||||||
} else if (rc == -1) {
|
} else if (rc == -1) {
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
throw Error("BUG: while %s, waitpid for evaluation worker failed: %s",
|
throw Error(
|
||||||
msg, strerror(errno));
|
"BUG: while %s, waitpid for evaluation worker failed: %s", msg,
|
||||||
|
strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
if (WEXITSTATUS(status) == 1) {
|
if (WEXITSTATUS(status) == 1) {
|
||||||
throw Error(
|
throw Error(
|
||||||
"while %s, evaluation worker exited with exit code 1, "
|
"while %s, evaluation worker exited with exit code 1, "
|
||||||
"(possibly an infinite recursion)",
|
"(possible infinite recursion)",
|
||||||
msg);
|
msg);
|
||||||
}
|
}
|
||||||
throw Error("while %s, evaluation worker exited with %d",
|
throw Error("while %s, evaluation worker exited with %d", msg,
|
||||||
msg, WEXITSTATUS(status));
|
WEXITSTATUS(status));
|
||||||
} else if (WIFSIGNALED(status)) {
|
} else if (WIFSIGNALED(status)) {
|
||||||
if (WTERMSIG(status) == SIGKILL) {
|
switch (WTERMSIG(status)) {
|
||||||
|
case SIGKILL:
|
||||||
throw Error(
|
throw Error(
|
||||||
"while %s, evaluation worker got killed by SIGKILL, maybe "
|
"while %s, evaluation worker got killed by SIGKILL, "
|
||||||
|
"maybe "
|
||||||
"memory limit reached?",
|
"memory limit reached?",
|
||||||
msg);
|
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(
|
throw Error(
|
||||||
"while %s, evaluation worker got killed by signal %d (%s)",
|
"while %s, evaluation worker got killed by signal %d (%s)",
|
||||||
|
@ -147,7 +165,7 @@ void handleBrokenWorkerPipe(Proc &proc, std::string_view msg) {
|
||||||
|
|
||||||
std::string joinAttrPath(json &attrPath) {
|
std::string joinAttrPath(json &attrPath) {
|
||||||
std::string joined;
|
std::string joined;
|
||||||
for (auto& element : attrPath) {
|
for (auto &element : attrPath) {
|
||||||
if (!joined.empty()) {
|
if (!joined.empty()) {
|
||||||
joined += '.';
|
joined += '.';
|
||||||
}
|
}
|
||||||
|
@ -220,7 +238,8 @@ void collector(Sync<State> &state_, std::condition_variable &wakeup) {
|
||||||
/* Wait for the response. */
|
/* Wait for the response. */
|
||||||
auto respString = fromReader->readLine();
|
auto respString = fromReader->readLine();
|
||||||
if (respString.empty()) {
|
if (respString.empty()) {
|
||||||
auto msg = "reading result for attrPath '" + joinAttrPath(attrPath) + "'";
|
auto msg = "reading result for attrPath '" +
|
||||||
|
joinAttrPath(attrPath) + "'";
|
||||||
handleBrokenWorkerPipe(*proc.get(), msg);
|
handleBrokenWorkerPipe(*proc.get(), msg);
|
||||||
}
|
}
|
||||||
json response;
|
json response;
|
||||||
|
|
|
@ -116,5 +116,5 @@ def test_recursion_error() -> None:
|
||||||
)
|
)
|
||||||
assert res.returncode == 1
|
assert res.returncode == 1
|
||||||
print(res.stderr)
|
print(res.stderr)
|
||||||
assert 'packageWithInfiniteRecursion' in res.stderr
|
assert "packageWithInfiniteRecursion" in res.stderr
|
||||||
assert "possible infinite recursion" in res.stderr
|
assert "possible infinite recursion" in res.stderr
|
||||||
|
|
Loading…
Reference in a new issue