Subject: kpsignal2 panic
To: None <tech-kern@netbsd.org>
From: Andrey Petrov <petrov@netbsd.org>
List: tech-kern
Date: 10/03/2003 14:54:12
Hi,

I upgraded pc164 alpha to very recent -current and found it panicing
right on exiting from emacs with display on another machine. The traceback
is (no serial console, just an excerpt)

kpsignal1
fownsignal
sowakeup
tcp_input
...

I guess it some races during process termination and signals because
the following patch helps to avoid the panic. It certainly needs
more investigation but hopefully it'll ring a bell to someone.

	Andrey

Index: kern_sig.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_sig.c,v
retrieving revision 1.163
diff -u -p -r1.163 kern_sig.c
--- kern_sig.c  3 Oct 2003 17:51:13 -0000       1.163
+++ kern_sig.c  3 Oct 2003 21:48:24 -0000
@@ -965,6 +965,15 @@ kpsignal1(struct proc *p, ksiginfo_t *ks
                size_t fd;
                struct filedesc *fdp = p->p_fd;
                ksi->ksi_fd = -1;
+
+               if (fdp == NULL) {
+#if 0
+                       printf("kpsignal1: fdp NULL, proc %d %d\n",
+                              p->p_pid, p->p_stat);
+#endif
+                       return;
+               }
+
                for (fd = 0; fd < fdp->fd_nfiles; fd++) {
                        struct file *fp = fdp->fd_ofiles[fd];
                        /* XXX: lock? */