Date: Sat, 22 Aug 2009 22:10:57 +0100 From: Bruce Cran <bruce@cran.org.uk> To: Thomas Backman <serenity@exscape.org> Cc: FreeBSD current <freebsd-current@freebsd.org> Subject: Re: ps -axl during textdumps occasionally segfaults with a HUGE ps.core Message-ID: <20090822221057.5429428c@gluon.draftnet> In-Reply-To: <665DE2F7-0899-40B7-9129-2082F2188D3E@exscape.org> References: <665DE2F7-0899-40B7-9129-2082F2188D3E@exscape.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 29 Jul 2009 22:19:47 +0200 Thomas Backman <serenity@exscape.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090822221057.5429428c>