[PATCH] zdtm: Fix pthread01 test case

Cyrill Gorcunov gorcunov at openvz.org
Wed Nov 14 15:13:19 EST 2012


 - use pthread_sigmask instead of sigprocmask
 - show_sigset should take the size of dereferenced variable
 - zeroify sigsets before use, since libc has own definition
   for sigset which doesn't match one the kernel uses

http://bugzilla.openvz.org/show_bug.cgi?id=2437

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm/live/static/pthread01.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/test/zdtm/live/static/pthread01.c b/test/zdtm/live/static/pthread01.c
index 50d381d..28d42b4 100644
--- a/test/zdtm/live/static/pthread01.c
+++ b/test/zdtm/live/static/pthread01.c
@@ -33,7 +33,7 @@ static void show_sigset(const sigset_t *s)
 	char buf[1024];
 	size_t i;
 
-	for (i = 0; i < sizeof(s); i++)
+	for (i = 0; i < sizeof(*s); i++)
 		sprintf(&buf[i * 2], "%02x", p[i]);
 	test_msg("sigset: %s\n", buf);
 }
@@ -42,15 +42,15 @@ static void *ch_thread_2(void *arg)
 {
 	char __tls_data[sizeof(tls_data.rand_string)] = "XM5o:?B*[a";
 	int *results_map = arg;
-	sigset_t blk_sigset;
-	sigset_t new;
+	sigset_t blk_sigset = { };
+	sigset_t new = { };
 
 	memcpy(tls_data.rand_string, __tls_data, sizeof(tls_data.rand_string));
 
 	sigemptyset(&blk_sigset);
 	sigprocmask(SIG_SETMASK, NULL, &blk_sigset);
 	sigaddset(&blk_sigset, SIGFPE);
-	sigprocmask(SIG_SETMASK, &blk_sigset, NULL);
+	pthread_sigmask(SIG_SETMASK, &blk_sigset, NULL);
 	memcpy(&tls_data.blk_sigset, &blk_sigset, sizeof(tls_data.blk_sigset));
 
 	task_waiter_complete(&t2, 1);
@@ -68,7 +68,7 @@ static void *ch_thread_2(void *arg)
 	} else
 		results_map[4] = 1;
 
-	sigprocmask(SIG_SETMASK, NULL, &new);
+	pthread_sigmask(SIG_SETMASK, NULL, &new);
 	if (memcmp(&tls_data.blk_sigset, &new, sizeof(tls_data.blk_sigset))) {
 		err("Failed to restore blk_sigset in thread 2\n");
 		results_map[6] = -1;
@@ -85,15 +85,15 @@ static void *ch_thread_1(void *arg)
 {
 	char __tls_data[sizeof(tls_data.rand_string)] = "pffYQSBo?6";
 	int *results_map = arg;
-	sigset_t blk_sigset;
-	sigset_t new;
+	sigset_t blk_sigset = { };
+	sigset_t new = { };
 
 	memcpy(tls_data.rand_string, __tls_data, sizeof(tls_data.rand_string));
 
 	sigemptyset(&blk_sigset);
 	sigprocmask(SIG_SETMASK, NULL, &blk_sigset);
 	sigaddset(&blk_sigset, SIGTRAP);
-	sigprocmask(SIG_SETMASK, &blk_sigset, NULL);
+	pthread_sigmask(SIG_SETMASK, &blk_sigset, NULL);
 	memcpy(&tls_data.blk_sigset, &blk_sigset, sizeof(tls_data.blk_sigset));
 
 	task_waiter_complete(&t1, 1);
@@ -112,7 +112,7 @@ static void *ch_thread_1(void *arg)
 		results_map[3] = 1;
 
 	sigemptyset(&new);
-	sigprocmask(SIG_SETMASK, NULL, &new);
+	pthread_sigmask(SIG_SETMASK, NULL, &new);
 	if (memcmp(&tls_data.blk_sigset, &new, sizeof(tls_data.blk_sigset))) {
 		err("Failed to restore blk_sigset in thread 1\n");
 		results_map[5] = -1;
-- 
1.7.7.6


--FCuugMFkClbJLl1L--


More information about the CRIU mailing list