From 77a0c2073a603ce6698f3667036e62a572cbb37c Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Mon, 25 Jan 2021 09:55:03 -0800 Subject: compiler_wrapper: loop in exec on ERESTARTSYS Very rarely on old GCCs, we'll see an ERESTARTSYS that fails builders. Kernel documentation indicates that users should never see ERESTARTSYS, but it's unclear how to fix this, so try to work around it for now. BUG=chromium:1166017 TEST=CQ Change-Id: I5a1ca6ce722f929523feb45aeafffcc30dfda05a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2647869 Reviewed-by: Manoj Gupta Tested-by: George Burgess --- compiler_wrapper/libc_exec.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler_wrapper/libc_exec.go b/compiler_wrapper/libc_exec.go index d9867733..09f8be85 100644 --- a/compiler_wrapper/libc_exec.go +++ b/compiler_wrapper/libc_exec.go @@ -18,7 +18,19 @@ package main // // Since fork() brings us to one thread, we can only use async-signal-safe funcs below. // pid_t pid = fork(); // if (pid == 0) { -// execve(pathname, argv, envp); +// // crbug.com/1166017: we're (very rarely) getting ERESTARTSYS on some builders. +// // Documentation indicates that this is a bug in the kernel. Work around it by +// // retrying. 25 is an arbitrary retry number that Should Be Enough For Anyone(TM). +// for (int i = 0; i < 25; i++) { +// execve(pathname, argv, envp); +// if (errno != 512) { +// break; +// } +// // Sleep a bit. Not sure if this helps, but if the condition we're seeing is +// // transient, it *hopefully* should. nanosleep isn't async-signal safe, so +// // we have to live with sleep() +// sleep(1); +// } // fprintf(stderr, "exec failed (errno: %d)\n", errno); // _exit(1); // } -- cgit v1.2.3