Skip to content

Commit

Permalink
zdtm/ptrace_sig: don't print from signal handlers
Browse files Browse the repository at this point in the history
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@entry=0x40458c "PASS\n") at msg.c:51
 #12 0x0000000000401ceb in main (argc=<optimized out>, argv=<optimized out>) at ptrace_sig.c:172

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Tested-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
  • Loading branch information
avagin authored and xemul committed Jun 7, 2016
1 parent 85da772 commit 860dafd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
27 changes: 7 additions & 20 deletions test/zdtm/static/ptrace_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion test/zdtm/static/ptrace_sig.desc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{'flags': 'noauto'}
{'flags': 'crfail'}

0 comments on commit 860dafd

Please sign in to comment.