From owner-freebsd-current@FreeBSD.ORG Mon Aug 24 22:01:52 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67354106568E for ; Mon, 24 Aug 2009 22:01:52 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (muon.cran.org.uk [66.246.138.153]) by mx1.freebsd.org (Postfix) with ESMTP id 4429A8FC14 for ; Mon, 24 Aug 2009 22:01:52 +0000 (UTC) Received: from gluon.draftnet (87-194-158-129.bethere.co.uk [87.194.158.129]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by muon.cran.org.uk (Postfix) with ESMTPSA id 34F0F851A for ; Mon, 24 Aug 2009 22:01:51 +0000 (UTC) Date: Mon, 24 Aug 2009 23:01:45 +0100 From: Bruce Cran To: current@freebsd.org Message-ID: <20090824230145.75824e5f@gluon.draftnet> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.4; i386-portbld-freebsd7.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Subject: patches to fix "ps -M" as used in crashinfo(8) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2009 22:01:52 -0000 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