patches to fix "ps -M" as used in crashinfo(8)
bruce at cran.org.uk
Mon Aug 24 22:01:52 UTC 2009
I've recently been debugging a series of problems with running ps(1) on
crash dumps, and now have a couple of patches: the bugs cause
ps(1) to crash while crashinfo(8) is being run during boot, dumping a
1GB ps.core file in the root filesystem.
The patches are at
The problem with ps.c is that like pkill(1) and w(1), they all
initialize the execfile argument to kvm_open or kvm_openfiles to
"/dev/null" instead of NULL, causing the default usage of "ps
-M /var/crash/vmcore.x" to fail because libkvm fails to
fstat /dev/null. They only work if "-N" is also specified.
There are also two bugs in libkvm: firstly the return code from
kvm_nlist wasn't being checked and as a result the code was walking off
the end of an array (it assumes kvm_nlist returns a positive number,
when it returns -1) - the original patch is at
http://people.freebsd.org/~gavin/PRs/137890.2.diff . After the bug in
ps.c was fixed it seems that changes to ucred.cr_groups was causing a
crash in bcopy. Translating the address using KREAD appears to work,
but not being familiar with the kernel interface I don't know if that's
the correct solution.
More information about the freebsd-current