[CRIU] [PATCH] zdtm/ptrace_sig: don't print from signal handlers

Andrey Vagin avagin at openvz.org
Thu Jun 2 12:42:46 PDT 2016


It can be dead-lokced:
 #0  0x00007fafbf49f6ac in __lll_lock_wait_private () from /lib64/libc.so.6
 #1  0x00007fafbf44af1c in _L_lock_2460 () from /lib64/libc.so.6
 #2  0x00007fafbf44ad57 in __tz_convert () from /lib64/libc.so.6
 #3  0x00000000004022e2 in test_msg (format=0x404508 "Receive signal %d\n") at msg.c:51
 #4  <signal handler called>
 #5  0x00007fafbf3f2483 in __GI__IO_vfscanf () from /lib64/libc.so.6
 #6  0x00007fafbf408f27 in vsscanf () from /lib64/libc.so.6
 #7  0x00007fafbf4032f7 in sscanf () from /lib64/libc.so.6
 #8  0x00007fafbf449ba6 in __tzset_parse_tz () from /lib64/libc.so.6
 #9  0x00007fafbf44c4cb in __tzfile_compute () from /lib64/libc.so.6
 #10 0x00007fafbf44ae17 in __tz_convert () from /lib64/libc.so.6
 #11 0x00000000004022e2 in test_msg (format=format at entry=0x40458c "PASS\n") at msg.c:51
 #12 0x0000000000401ceb in main (argc=<optimized out>, argv=<optimized out>) at ptrace_sig.c:172

https://jira.sw.ru/browse/PSBM-47772

Signed-off-by: Andrey Vagin <avagin at openvz.org>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/ptrace_sig.c    | 27 +++++++--------------------
 test/zdtm/static/ptrace_sig.desc |  2 +-
 2 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/test/zdtm/static/ptrace_sig.c b/test/zdtm/static/ptrace_sig.c
index a8e1dc5..299605d 100644
--- a/test/zdtm/static/ptrace_sig.c
+++ b/test/zdtm/static/ptrace_sig.c
@@ -25,11 +25,6 @@ void sig_handler(int signo, siginfo_t *siginfo, void *data)
 	child_exit = 1;
 }
 
-void sig_chld_handler(int signo)
-{
-	test_msg("Receive signal %d\n", signo);
-}
-
 int child(int fd)
 {
 	int ret = 0;
@@ -64,7 +59,6 @@ int main(int argc, char ** argv)
 {
 	int ret, status = 0;
 	pid_t pid, spid, cpid;
-	sighandler_t sh;
 	int signal_pipe[2];
 	int child_pipe[2];
 
@@ -113,12 +107,6 @@ int main(int argc, char ** argv)
 	}
 	close(signal_pipe[0]);
 
-	sh = signal(SIGCHLD, sig_chld_handler);
-	if (sh == SIG_ERR) {
-		pr_perror("signal failed");
-		return 1;
-	}
-
 	test_msg("wait while child initialized");
 	ret = read(child_pipe[0], &status, sizeof(status));
 	if  (ret != sizeof(status)) {
@@ -166,24 +154,23 @@ int main(int argc, char ** argv)
 				return 1;
 			}
 
-			if (spid != siginfo.si_pid)
+			if (spid != siginfo.si_pid) {
 				fail("%d!=%d", cpid, siginfo.si_pid);
-			else if (status == siginfo.si_pid)
-				pass();
-			else {
+				return 1;
+			} else if (status != siginfo.si_pid) {
 				fail("%d!=%d", status, siginfo.si_pid);
 				return 1;
 			}
-		}
-		if (WIFEXITED(status)) {
+		} else if (WIFEXITED(status)) {
 			test_msg("pid = %d status = %d\n", pid, WEXITSTATUS(status));
 			if (WEXITSTATUS(status))
 				return 1;
-		}
-		if (WIFSTOPPED(status)) {
+		} else if (WIFSIGNALED(status)) {
 			test_msg("pid = %d signal = %d\n", pid, WTERMSIG(status));
 			return 1;
 		}
 	}
+
+	pass();
 	return 0;
 }
diff --git a/test/zdtm/static/ptrace_sig.desc b/test/zdtm/static/ptrace_sig.desc
index 95c58b4..ded8987 100644
--- a/test/zdtm/static/ptrace_sig.desc
+++ b/test/zdtm/static/ptrace_sig.desc
@@ -1 +1 @@
-{'flags': 'noauto'}
+{'flags': 'crfail'}
-- 
2.7.4



More information about the CRIU mailing list