From owner-freebsd-stable@FreeBSD.ORG Tue Oct 18 14:43:15 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2CA21065676 for ; Tue, 18 Oct 2011 14:43:15 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from QMTA11.westchester.pa.mail.comcast.net (qmta11.westchester.pa.mail.comcast.net [76.96.59.211]) by mx1.freebsd.org (Postfix) with ESMTP id 919A98FC14 for ; Tue, 18 Oct 2011 14:43:14 +0000 (UTC) Received: from omta14.westchester.pa.mail.comcast.net ([76.96.62.60]) by QMTA11.westchester.pa.mail.comcast.net with comcast id mEZt1h0021HzFnQ5BEjEcD; Tue, 18 Oct 2011 14:43:14 +0000 Received: from koitsu.dyndns.org ([67.180.84.87]) by omta14.westchester.pa.mail.comcast.net with comcast id mEjD1h02T1t3BNj3aEjEtW; Tue, 18 Oct 2011 14:43:14 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id A6AA8102C1C; Tue, 18 Oct 2011 07:43:12 -0700 (PDT) Date: Tue, 18 Oct 2011 07:43:12 -0700 From: Jeremy Chadwick To: Ivan Voras Message-ID: <20111018144312.GA17496@icarus.home.lan> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-stable@freebsd.org Subject: Re: Setting coredumpsize on a running process? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2011 14:43:16 -0000 On Tue, Oct 18, 2011 at 04:32:11PM +0200, Ivan Voras wrote: > I have PHP executing as fastcgi via the mod_fcgid module in Apache. I > suspect there is a bug in PHP or one of its extensions which causes it > to crash with sigsegv, but I cannot get any coredumps. I suspect > something is setting coredumpsize to 0 - either Apache, mod_fcgid or PHP. > > So the question is: is there a way to set coredumpsize on a running > process, with the intention of getting a core dump when it crashes? I > already tried setting CoreDumpDirectory in Apache and also configuring > apache22limits_args in /etc/rc.conf but without effect. I ended up solving this on a machine where coredumps with Apache + PHP were highly common by setting sysctl kern.corefile to /var/cores/%P.%N.core, then made sure the /var/cores directory was root:wheel, perms 1777. Otherwise I could not get a coredump. apache22limits_enable did not help either, nor did CoreDumpDirectory. Here's an example from that box: $ ls -ld /var/cores /var/cores/* drwxrwxrwt 2 root wheel 512 Oct 1 00:00 /var/cores/ -rw------- 1 root wheel 14360576 Oct 1 00:00 /var/cores/53964.httpd.core I imagine the issue might have to do with some cores being written by the UID/GID which crashed (in your case, could be 80:80), which I assume means the UID/GID needs to have write access to whatever it's cwd is at the time of the crash. Hence why setting kern.corefile to a static path where the dir is 1777 (globally writeable + sticky bit) works around that. Just be aware that if anything else cores on the system it'll end up there too. Also be aware that to get even remotely useful data out of PHP and Apache, you often have to rebuild everything with debugging enabled and optimisations disabled. That's semi-simple to do, but what may come as a surprise is that the path to the PHP modules ends up having "-debug" in it (I'm referring to /usr/local/lib/php/whatever), so you really do have to rebuild not just PHP and Apache but all PHP modules too given the path change. Worse, certain modules like either eAccelerator or ZendOptimizer (I forget which of the two) make the downright assumption that they are in use on a PHP system where debugging is not enabled, thus do not behave quite right when placed there. Having fun yet? -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, US | | Making life hard for others since 1977. PGP 4BD6C0CB |