uname -a FreeBSD xxx 12.1-STABLE FreeBSD 12.1-STABLE r363310 xxxx amd64 sysctl -a kern.ostype: FreeBSD kern.osrelease: 12.1-STABLE kern.osrevision: 199506 kern.version: FreeBSD 12.1-STABLE r363310 VOJEN kern.maxvnodes: 620153 kern.maxproc: 38036 kern.maxfiles: 1044518 kern.argmax: 524288 kern.securelevel: -1 kern.hostname: xxx kern.hostid: 2119532645 kern.clockrate: { hz = 1000, tick = 1000, profhz = 8128, stathz = 127 } <<<---- panic at eip 0x20:0xfffffff8058946b bt pget() at pget+0x200/frame 0xfffffe009f4987e0 sysctl_kern_proc_kstack() at sysctl_kern_proc_kstack+0x27 sysctl_root_handler_locked() at sysctl_root_handler_locked+0x7d sysctl_root() at sysctl_root+0x192 userland_sysctl() ... Source of panic is mismerge of kern_proc.c in 363038 at line 413, original was: } else { if (pid <= PID_MAX) { ... } else if ((flags & PGET_NOTID) == 0) { p = pfind_tid_locked(pid); } else { p = NULL; } revision 363038: } else { if (pid <= PID_MAX) { ... } else if ((flags & PGET_NOTID) == 0) { td1 = tdfind(pid, -1); if (td1 != NULL) p = td1->td_proc; } If tdfind() fails, p is not reset to NULL and also NOTID case was lost. Merge missed assignment p = NULL before if (pid <= PID_MAX): } else { p = NULL; /* THIS STATEMENT IS IN HEAD, NOT IN STABLE */ if (pid <= PID_MAX) { ... } else if ((flags & PGET_NOTID) == 0) { td1 = tdfind(pid, -1); if (td1 != NULL) p = td1->td_proc; } With this change, sysctl -a no longer panics.
A commit references this bug: Author: kib Date: Sat Jul 18 20:17:41 UTC 2020 New revision: 363312 URL: https://svnweb.freebsd.org/changeset/base/363312 Log: Fix mismerge of r363038. The reset of p to NULL for non-curproc was missed, cauing ESRCH error not returned as it should be. Reported by: lampa@fit.vutbr.cz PR: 248070 Changes: stable/12/sys/kern/kern_proc.c