Date: Sun, 15 Feb 2015 08:44:30 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278795 - head/sys/kern Message-ID: <201502150844.t1F8iUVR006560@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sun Feb 15 08:44:30 2015 New Revision: 278795 URL: https://svnweb.freebsd.org/changeset/base/278795 Log: Reparenting done by debugger attach can leave reaper without direct children. Handle the situation instead asserting that it is impossible. Reported and tested by: emaste Sponsored by: The FreeBSD Foundation MFC after: 3 days Modified: head/sys/kern/kern_procctl.c Modified: head/sys/kern/kern_procctl.c ============================================================================== --- head/sys/kern/kern_procctl.c Sun Feb 15 08:43:19 2015 (r278794) +++ head/sys/kern/kern_procctl.c Sun Feb 15 08:44:30 2015 (r278795) @@ -160,7 +160,7 @@ static int reap_status(struct thread *td, struct proc *p, struct procctl_reaper_status *rs) { - struct proc *reap, *p2; + struct proc *reap, *p2, *first_p; sx_assert(&proctree_lock, SX_LOCKED); bzero(rs, sizeof(*rs)); @@ -176,8 +176,10 @@ reap_status(struct thread *td, struct pr rs->rs_descendants = 0; rs->rs_children = 0; if (!LIST_EMPTY(&reap->p_reaplist)) { - KASSERT(!LIST_EMPTY(&reap->p_children), ("no children")); - rs->rs_pid = LIST_FIRST(&reap->p_children)->p_pid; + first_p = LIST_FIRST(&reap->p_children); + if (first_p == NULL) + first_p = LIST_FIRST(&reap->p_reaplist); + rs->rs_pid = first_p->p_pid; LIST_FOREACH(p2, &reap->p_reaplist, p_reapsibling) { if (proc_realparent(p2) == reap) rs->rs_children++;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502150844.t1F8iUVR006560>