Module Name: src Committed By: martin Date: Tue Oct 15 19:27:04 UTC 2019
Modified Files: src/sys/kern [netbsd-9]: kern_sig.c Log Message: Pull up following revision(s) (requested by kamil in ticket #329): sys/kern/kern_sig.c: revision 1.371 Fix one the the root causes of unreliability of the ptrace(2)ed threads In case of sigswitchin away in issignal() and continuing the execution on PT_CONTINUE (or equivalent call), there is a time window when another thread could cause the process state to be changed to PS_STOPPING. In the current logic, a thread would receive signal 0 (no-signal) and exit from issignal(), returning to userland and never finishing the process of stopping all LWPs. This causes hangs waitpid() waiting for SIGCHLD and the callout polling for the state of the process in an infinite loop. Instead of prompting for a returned signal from a debugger, repeat the issignal() loop, this will cause checking the PS_STOPPING flag again and sigswitching away in the scenario of stopping the process. To generate a diff of this commit: cvs rdiff -u -r1.364.2.5 -r1.364.2.6 src/sys/kern/kern_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.364.2.5 src/sys/kern/kern_sig.c:1.364.2.6 --- src/sys/kern/kern_sig.c:1.364.2.5 Tue Oct 15 19:25:11 2019 +++ src/sys/kern/kern_sig.c Tue Oct 15 19:27:04 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.364.2.5 2019/10/15 19:25:11 martin Exp $ */ +/* $NetBSD: kern_sig.c,v 1.364.2.6 2019/10/15 19:27:04 martin Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.364.2.5 2019/10/15 19:25:11 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.364.2.6 2019/10/15 19:27:04 martin Exp $"); #include "opt_ptrace.h" #include "opt_dtrace.h" @@ -1863,7 +1863,7 @@ issignal(struct lwp *l) if (p->p_stat == SSTOP || (p->p_sflag & PS_STOPPING) != 0) { sigswitch_unlock_and_switch_away(l); mutex_enter(p->p_lock); - signo = sigchecktrace(); + continue; } else if (p->p_stat == SACTIVE) signo = sigchecktrace(); else