NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/50318: Process p_nstopchild counter not updated in suspendsched()



>Number:         50318
>Category:       kern
>Synopsis:       Process p_nstopchild counter not updated in suspendsched()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 09 04:35:00 +0000 2015
>Originator:     paul%whooppee.com@localhost
>Release:        NetBSD 7.99.21
>Organization:
+------------------+--------------------------+-------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
+------------------+--------------------------+-------------------------+
>Environment:
	
	
System: NetBSD pokey.whooppee.com 7.99.21 NetBSD 7.99.21 (POKEY 2015-10-08 12:18:09) #0: Fri Oct 9 10:41:35 PHT 2015 paul%pokey.whooppee.com@localhost:/build/netbsd-local/obj/amd64/sys/arch/amd64/compile/POKEY amd64
Architecture: x86_64
Machine: amd64
>Description:
	During system shutdown, immediately before syncing the disks,
	we call suspendsched() to clean up the scheduler queues.  For
	each process, we blindly set its p_stat to SSTOP but we do
	not update the parent's count of stopped children.  There is
	thus a small window where a process (usually, init) can call
	waitpid() with an inconsistent counter.

	There doesn't seem to be much real harm done here, however
	it seems to me that we really should keep the data updated
	correctly.
	
>How-To-Repeat:
	Found by code inspection while investigating a related issue
	(zombie process never getting reaped).
	
>Fix:

Index: kern_synch.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_synch.c,v
retrieving revision 1.308
diff -u -p -r1.308 kern_synch.c
--- kern_synch.c	28 Feb 2014 10:16:51 -0000	1.308
+++ kern_synch.c	9 Oct 2015 04:25:18 -0000
@@ -985,7 +985,13 @@ suspendsched(void)
 			continue;
 		}
 
-		p->p_stat = SSTOP;
+/* XXX PRG */
+		if (p->p_stat != SSTOP) {
+			if (p->p_stat != SZOMB && p->p_stat != SDEAD)
+				p->p_pptr->p_nstopchild++;
+			p->p_stat = SSTOP;
+		}
+/* XXX PRG */
 
 		LIST_FOREACH(l, &p->p_lwps, l_sibling) {
 			if (l == curlwp)

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index