Module Name:    src
Committed By:   kamil
Date:           Tue Oct 15 13:59:57 UTC 2019

Modified Files:
        src/sys/kern: kern_sig.c

Log Message:
Remove the short-circuit lwp_exit() path from sigswitch()

sigswitch() can be called from exit1() through:

   ttywait()->ttysleep()-> 
cv_timedwait_sig()->sleepq_block()->issignal()->sigswitch()

lwp_exit() called for the last LWP triggers exit1() and this causes a panic.

The debugger related signals have short-circuit demise paths in
eventswitch() and other functions, before calling sigswitch().

This change restores the original behavior, but there is an open question
whether the kernel crash is a red herring of misbehavior of ttywait().

This should fix PR kern/54618 by David H. Gutteridge


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 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.372 src/sys/kern/kern_sig.c:1.373
--- src/sys/kern/kern_sig.c:1.372	Sun Oct 13 03:50:26 2019
+++ src/sys/kern/kern_sig.c	Tue Oct 15 13:59:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.372 2019/10/13 03:50:26 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.373 2019/10/15 13:59:57 kamil 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.372 2019/10/13 03:50:26 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.373 2019/10/15 13:59:57 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1713,21 +1713,6 @@ sigswitch(int ppmask, int signo, bool pr
 	}
 
 	/*
-	 * If we are exiting, demise now.
-	 *
-	 * This avoids notifying tracer and deadlocking.
-	 */
-	if (__predict_false(ISSET(p->p_sflag, PS_WEXIT))) {
-		mutex_exit(p->p_lock);
-		if (proc_lock_held) {
-			mutex_exit(proc_lock);
-		}
-		lwp_exit(l);
-		panic("sigswitch");
-		/* NOTREACHED */
-	}
-
-	/*
 	 * On entry we know that the process needs to stop.  If it's
 	 * the result of a 'sideways' stop signal that has been sourced
 	 * through issignal(), then stop other LWPs in the process too.

Reply via email to