Date: Mon, 24 Aug 2009 23:01:45 +0100 From: Bruce Cran <bruce@cran.org.uk> To: current@freebsd.org Subject: patches to fix "ps -M" as used in crashinfo(8) Message-ID: <20090824230145.75824e5f@gluon.draftnet>
next in thread | raw e-mail | index | archive | help
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 http://www.cran.org.uk/~brucec/freebsd/pr137890.kvm_proc.c.diff and http://www.cran.org.uk/~brucec/freebsd/pr137890.ps.c.diff 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. -- Bruce Cran
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090824230145.75824e5f>