From owner-freebsd-current@FreeBSD.ORG Sat Aug 22 21:11:13 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8808D106568D for ; Sat, 22 Aug 2009 21:11:13 +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 5EE548FC19 for ; Sat, 22 Aug 2009 21:11:13 +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 910EC8465; Sat, 22 Aug 2009 21:11:11 +0000 (UTC) Date: Sat, 22 Aug 2009 22:10:57 +0100 From: Bruce Cran To: Thomas Backman Message-ID: <20090822221057.5429428c@gluon.draftnet> In-Reply-To: <665DE2F7-0899-40B7-9129-2082F2188D3E@exscape.org> References: <665DE2F7-0899-40B7-9129-2082F2188D3E@exscape.org> 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: FreeBSD current Subject: Re: ps -axl during textdumps occasionally segfaults with a HUGE ps.core 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: Sat, 22 Aug 2009 21:11:13 -0000 On Wed, 29 Jul 2009 22:19:47 +0200 Thomas Backman wrote: > All the info I happen to have: > > (from core.txt.X) > "ps -axl > > Segmentation fault (core dumped)" > > The last core I got (/ps.core) was 1076211712 bytes (1026 MiB). > > Anyone else with this problem? > Unfortunately, I deleted the most recent core and so can't gdb it, > at least not right now. I did try it on the first one, but got a > very broken backtrace. Can you try the patches at http://www.cran.org.uk/~brucec/libkvm_20090822.diff and http://www.cran.org.uk/~brucec/ps_20090822.diff please? I've tested them on both amd64 and i386 PCs and it seems to work. It turned out there were 3 bugs: 1. The call to kvm_nlist on line 558 of lib/libkvm/kvm_proc.c was failing with -1, but the code assumed it was returning a positive number and so ended up walking off the end of the array. gavin@ created the patch - a standalone version is at http://people.freebsd.org/~gavin/PRs/137890.2.diff but has been integrated into libkvm_20090822.diff. There may be more calls to kvm_nlist that don't have the correct error checking in kvm_proc.c 2. kvm_open(3) states that execfile can be NULL, but line 215 of bin/ps/ps.c initializes it to _PATH_DEVNULL. That was why kvm_nlist was failing. 3. On line 154 of kvm_proc.c bcopy is called with the address in ucred.cr_groups. It appears that it's a kernel address and I guess that an extra call to KREAD needs to be made. At the same time as fixing those bugs I bumped WARNS up and fixed the resulting errors: invalid formatting strings, casts and unused variables - and converted some functions from K&R to ANSI to try and get better warnings of any potential problems from gcc. I can split out the actual bug fixes into separate patches if needed. -- Bruce