Apply patch, requested by kamil in ticket #925:

Adaption of:

	tests/lib/libc/sys/t_ptrace_fork_wait.h	1.3,1.4,1.6

Ignore interception of SIGCHLD signals in the debugger

There is a race that SIGCHLD might be blocked during forking and dropped.

PR/55241 by Andreas Gustafsson
This commit is contained in:
martin 2020-05-25 17:06:52 +00:00
parent c09ceb6039
commit 5c25fe80f3
1 changed files with 8 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_ptrace_wait.c,v 1.131.2.7 2020/05/25 17:00:20 martin Exp $ */
/* $NetBSD: t_ptrace_wait.c,v 1.131.2.8 2020/05/25 17:06:52 martin Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131.2.7 2020/05/25 17:00:20 martin Exp $");
__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131.2.8 2020/05/25 17:06:52 martin Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -3041,6 +3041,8 @@ fork_body(const char *fn, bool trackspawn, bool trackfork, bool trackvfork,
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
sigblock(sigmask(SIGCHLD));
DPRINTF("Before raising %s from child\n", strsignal(sigval));
FORKEE_ASSERT(raise(sigval) == 0);
@ -3197,16 +3199,6 @@ fork_body(const char *fn, bool trackspawn, bool trackfork, bool trackvfork,
}
#endif
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGCHLD\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, SIGCHLD);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected exited\n",
TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
@ -3333,6 +3325,8 @@ fork_detach_forker_body(const char *fn, bool kill_process)
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
sigblock(sigmask(SIGCHLD));
DPRINTF("Before raising %s from child\n", strsignal(sigval));
FORKEE_ASSERT(raise(sigval) == 0);
@ -5763,6 +5757,8 @@ fork2_body(const char *fn, bool masked, bool ignored)
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
sigblock(sigmask(SIGCHLD));
if (masked) {
sigemptyset(&intmask);
sigaddset(&intmask, SIGTRAP);
@ -6062,16 +6058,6 @@ fork2_body(const char *fn, bool masked, bool ignored)
wpid = TWAIT_GENERIC(child2, &status, 0));
}
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGCHLD\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, SIGCHLD);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected exited\n",
TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);