Error running php-cgi

I keep getting this error in my postmaster account

sh: line 1: 28331 Segmentation fault /usr/bin/php5-cgi -v 2>&1 < /dev/null

Anyone have an idea how I can fix this?

Thanks
Lance

Hi Lance,

What do you get if you run this:

[code:1]/usr/bin/php5-cgi -v[/code:1]

Also, what distro are you using? And is your PHP package provided by your distro, or is it from a third party or perhaps manually compiled?
-Eric

Hi,

I am runnign Debian lenny and all packages are the default system ones.

This is the result of your question

[code:1]

mail:~# /usr/bin/php5-cgi -v
PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cgi-fcgi) (built: Apr 26 2009 22:11:16)
Copyright © 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright © 1998-2008 Zend Technologies
mail:~#

[/code:1]

Hrm, that much all looks normal.

What do you mean by you’re getting that error in your postmaster account – are you receiving it via email?

If so, what’s the full email message? Can you tell what command is being run to generate that?

Perhaps there’s something running from within cron that’s causing the error.
-Eric

Hi Eric,

I can’t see anything specific.

This is the body of the mail.

I will have a look at the perl file but I am no programmer.

[code:1]

From: root@mail.redarmour.co.uk (Cron Daemon)
To: root@mail.redarmour.co.uk
Subject: Cron <root@mail> /etc/webmin/virtual-server/collectinfo.pl
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
Message-Id: <20090509170504.5C23C88EC4@mail.redarmour.co.uk>
Date: Sat, 9 May 2009 18:05:03 +0100 (BST)
X-Evolution-Source: imap://redarmour@mail.redarmour.co.uk/
Mime-Version: 1.0

sh: line 1: 28331 Segmentation fault /usr/bin/php5-cgi -v 2>&1 < /dev/null

[/code:1]

This has nothing to do with Perl. php-cgi is segfaulting, I guess intermittently since it seemed to run OK when run manually.

Is this a VPS (specifically an OpenVZ or Virtuozzo instance)? Could be related to memory fragmentation.

Do you have swap enabled?

How much free memory do you normally have?

Anyway, I’m guessing it occurs when there’s a bit of extra memory usage and php-cgi can’t grab enough (it should give a memory allocation error, though, so it could be something else).

I’m having a similar problem and it seems to be related to the php5-mysql package (on Debian Lenny). Just by running “php -v” from the command-line I seem to constantly run into the problem.

ii php5-mysql 5.2.6.dfsg.1-1+lenny3 MySQL module for php5

To be honest, I’m at a loss for words. I verified this problem on a completely seperate debian-lenny instance and “php -v” will consistely segfault on me. Any ideas? I really need to be able to access mysql5 dbs from php.

Howdy,

Can you offer the full output of this command:

dpkg -l ‘php*’ | grep ‘ii’

Also, is anything in /etc/security/limits.conf?

-Eric

Sure. This is fresh install of debian lenny on a virtual-host and then using the install.sh script and then added php-mysql.

fire:~# dpkg -l 'php*' | grep 'ii' ii php-pear 5.2.6.dfsg.1-1+lenny3 PEAR - PHP Extension and Application Repository ii php5 5.2.6.dfsg.1-1+lenny3 server-side, HTML-embedded scripting language ( ii php5-cgi 5.2.6.dfsg.1-1+lenny3 server-side, HTML-embedded scripting language ( ii php5-cli 5.2.6.dfsg.1-1+lenny3 command-line interpreter for the php5 scripting ii php5-common 5.2.6.dfsg.1-1+lenny3 Common files for packages built from the php5 s ii php5-mysql 5.2.6.dfsg.1-1+lenny3 MySQL module for php5 fire:~# cat /etc/security/limits.conf | grep -v '#' fire:~# cat /etc/apt/sources.list

the main Debian packages.

deb http://mirror.cc.columbia.edu/pub/linux/debian/debian/ lenny main contrib

Uncomment the deb-src line if you want ‘apt-get source’

to work with most packages.

deb-src http://mirror.cc.columbia.edu/pub/linux/debian/debian/ lenny main contrib

uncommenting the following line will enable security updates

deb http://security.debian.org/ stable/updates main contrib
deb http://software.virtualmin.com/gpl/debian/ virtualmin-lenny main
deb http://software.virtualmin.com/gpl/debian/ virtualmin-universal main

fire:~# php -v PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 22:16:23) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies Segmentation fault fire:~# strace php -v

#SNIP# #SNIP# #SNIP#

write(1, “PHP 5.2.6-1+lenny3 with Suhosin-P”…, 183PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 22:16:23)
Copyright © 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright © 1998-2008 Zend Technologies
) = 183
open("/dev/urandom", O_RDONLY) = 3
read(3, “R\17\317k”…, 4) = 4
close(3) = 0
open("/dev/urandom", O_RDONLY) = 3
read(3, “8\362\25\371”…, 4) = 4
close(3) = 0
open("/dev/urandom", O_RDONLY) = 3
read(3, “!W)\375”…, 4) = 4
close(3) = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
futex(0xb7f2d260, FUTEX_WAIT, 2, NULL) = 0
munmap(0xb7408000, 27592) = 0
futex(0xb7f2d260, FUTEX_WAKE, 1) = 0
munmap(0xb740f000, 89980) = 0
gettimeofday({1249311178, 678191}, NULL) = 0
munmap(0xb7425000, 101552) = 0
munmap(0xb7629000, 43776) = 0
munmap(0xb743e000, 2010808) = 0
+++ killed by SIGSEGV +++

Well isn’t that odd :slight_smile:

Does anything show up in /var/log/kern.log when that dies off?

How much RAM is in your machine? You can see that with the “free” command.

Thanks,

-Eric

FYI, I found a debian bug on this problem.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=493045

I’m still reading through all the replies, hopefully there’s a package from “proposed” that will fix this problem. :frowning:

Nope, nothing shows up in the kernel log. As for memory, it is a smaller system but in this particular case, very little is running.

fire:/etc/php5/cli# free -m total used free shared buffers cached Mem: 540 376 163 0 35 154 -/+ buffers/cache: 186 353 Swap: 255 0 255

Well, the fact that you have some available RAM, as well as swap setup, means PHP should at least run.

Are you by chance on a VPS?

But yeah, as you saw, it looks like it could be a Debian issue. This came up for someone else in the VM bugtracker recently as well, so you aren’t the only one :slight_smile:

-Eric

@Eric - Thank you for your help in trying to debug this problem. Yes, this is a VPS.

For others, this appears to be an SMP problem and has been documented both here and here.

Near the bottom of both threads is a patched libmysqlclient1off that has solved the problem for me. You can grab the deb here.

Up until now I’ve been a strictly ubuntu guy but recently made the switch to debian lenny because I’ve heard that it can be better for server environments. This bug has me shaken up a bit but I’ll trudge on before I give up good 'ole debian.

This fixed my problem as well.

Thanks

Lance