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

Andrey Vagin avagin at openvz.org
Tue Nov 17 04:35:38 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)

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

diff --git a/include/lock.h b/include/lock.h
index 392318e..84bca18 100644
--- a/include/lock.h
+++ b/include/lock.h
@@ -50,7 +50,10 @@ 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;			\
+			pr_err("futex() returned an unexpected error: %d\n", ret); \
+			BUG_ON(ret < 0);			\
 		}						\
 	} while (0)
 
-- 
2.4.3



More information about the CRIU mailing list