[CRIU] [PATCH] lock: futex() with timeout isn't restarted after signals (v2)

Andrey Vagin avagin at openvz.org
Wed Nov 18 01:44:10 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

It returns EINTR, so we need to handle it.

$ bash test/zdtm.sh --restore-sibling ns/static/env00
...
futex(0x7fc20ec92010, FUTEX_WAIT, 1, {120, 0}) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_TRAPPED, si_pid=15188, si_uid=0, si_status=SIGCHLD, si_utime=0, si_stime=0} ---
ptrace(PTRACE_CONT, 15188, 0, SIGCHLD)  = 0
rt_sigreturn({mask=~[KILL CHLD STOP RTMIN RT_1]}) = -1 EINTR (Interrupted system call)

v2: print the error message only in error cases

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 include/lock.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/lock.h b/include/lock.h
index 392318e..734132c 100644
--- a/include/lock.h
+++ b/include/lock.h
@@ -50,7 +50,12 @@ static inline void futex_set(futex_t *f, u32 v)
 				pr_warn("blocked for more than 120 seconds\n"); \
 				continue;			\
 			}					\
-			BUG_ON(ret < 0 && ret != -EWOULDBLOCK);	\
+			if (ret == -EINTR || ret == -EWOULDBLOCK) \
+				continue;			\
+			if (ret < 0) {				\
+				pr_err("futex() returned an unexpected error: %d\n", ret); \
+				BUG();				\
+			}					\
 		}						\
 	} while (0)
 
-- 
2.4.3



More information about the CRIU mailing list