# PHP causes segfault in Apache [solved]

## rlucking

I've got a few gentoo servers set up in various places, and can generally sort the "issues" out, but this one is bugging me...

It's a small local server which runs apache+php, but for a couple of weeks (since something was upgraded, i guess), enabling "-D PHP5" in APACHE2_OPTS stops apache working with the following errors in error_log whenever anything is requested:

```
[Tue Aug 25 23:19:02 2009] [notice] child pid 12668 exit signal Segmentation fault (11)

[Wed Aug 26 09:27:29 2009] [notice] child pid 12669 exit signal Segmentation fault (11)

```

etc

Taking out the -D PHP5 and everything (except php!) works fine.

I've recompiled *everything* (-e system, then -e world at least twice), I've deleted everything to do with apache and php and reinstalled them... still the same.

They are installed with the following flags:

```
[ebuild   R   ] www-servers/apache-2.2.11-r2  USE="ldap ssl -debug -doc (-selinux) -sni -static -suexec -threads" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias -asis -auth_digest -authn_dbd -cern_meta -charset_lite -dbd -dumpio -ident -imagemap -log_forensic -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -substitute -version" APACHE2_MPMS="-event -itk -peruser -prefork -worker" 0 kB

[ebuild   R   ] dev-lang/php-5.2.10  USE="apache2 berkdb bzip2 cgi cli crypt curl gdbm iconv json ldap ncurses pcre pdo readline reflection session spl ssl unicode xml zlib -adabas -bcmath -birdstep -calendar -cdb -cjk -concurrentmodphp -ctype -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -exif -fastbuild -fdftk -filter -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd -gd-external -gmp -hash -imap -inifile -interbase -iodbc -ipv6 (-java-external) -kerberos -kolab -ldap-sasl -libedit -mcve -mhash -msql -mssql -mysql -mysqli -nls -oci8 -oci8-instant-client -odbc -pcntl -pic -posix -postgres -qdbm -recode -sapdb -sharedext -sharedmem -simplexml -snmp -soap -sockets -solid -spell -sqlite -suhosin -sybase -sybase-ct -sysvipc -threads -tidy -tokenizer -truetype -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -yaz -zip" 0 kB

```

Any suggestions as to anything else which might be causing the segfault, please let me know!

RichLast edited by rlucking on Fri Aug 28, 2009 2:45 pm; edited 1 time in total

----------

## malern

Your USE flags look pretty standard, I run a very similar install with no problems. Could you post the output of "emerge --info"

----------

## rlucking

 *malern wrote:*   

> Your USE flags look pretty standard, I run a very similar install with no problems. Could you post the output of "emerge --info"

 

As far as I can recall it's a fairly standard box... been steadily updated over the months/years, but nothing too drastic (that I recall, anyway!).

```
# emerge --info

Portage 2.1.6.13 (default/linux/x86/2008.0, gcc-4.3.2, glibc-2.9_p20081201-r2, 2.6.30-gentoo-r4 i686)

=================================================================

System uname: Linux-2.6.30-gentoo-r4-i686-VIA_Nehemiah-with-gentoo-1.12.11.1

Timestamp of tree: Tue, 25 Aug 2009 23:00:01 +0000

app-shells/bash:     3.2_p39

dev-lang/python:     2.5.4-r3, 2.6.2-r1

dev-python/pycrypto: 2.0.1-r8

sys-apps/baselayout: 1.12.11.1

sys-apps/sandbox:    1.6-r2

sys-devel/autoconf:  2.63-r1

sys-devel/automake:  1.4_p6, 1.5, 1.7.9-r1, 1.10.2

sys-devel/binutils:  2.18-r3

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.27-r2

ACCEPT_KEYWORDS="x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-march=c3-2 -O2 -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /var/bind"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"

CXXFLAGS="-march=c3-2 -O2 -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"

LDFLAGS="-Wl,-O1"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="apache2 berkdb bzip2 cli cracklib crypt dri gdbm iconv isdnlog jpeg ldap mbox mudflap ncurses nptl nptlonly openmp pam pcre perl png pppd python readline reflection session spl ssl sysfs tcpd unicode x86 xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY

```

----------

## malern

That looks fine as well. Maybe try compiling without the "-march=c3-2" option, just to narrow it down, but really I'm just grasping at straws.

Maybe someone else can explain the best way to debug a segfault. But really, if it's segfaulting then it's either a hardware problem or a bug, so if you think your hardware is ok you might as well just submit it to bugs.gentoo.org.

----------

## rlucking

Thanks - I might try that! I'm currently having a "tidy up". After doing all the -e rebuilds, there are quite a few lib/bin/sbin/etc files which weren't rebuilt, so I'm moving them to temporary directories, and revdep-rebuilding to see what is broken, then fixing it! Hopefully that'll mean *everything* is up to date - there were files dating back to 2003, and I'm sure the server isn't *that* old!

Fingers crossed  :Smile: 

Rich

----------

## beandog

You know, I had random segfaults with 5.2.10 as well ... figured I did something wrong.  I just ended up going back to 5.2.9 instead of dealing with it.

----------

## cach0rr0

 *beandog wrote:*   

> You know, I had random segfaults with 5.2.10 as well ... figured I did something wrong.  I just ended up going back to 5.2.9 instead of dealing with it.

 

seen the same with a ton of my customers at work. Never paid it much mind.

----------

## rlucking

Getting somewhere! Playing around - apache would display an error or a directory listing, but any files at all and it segfaulted. Clearing out the old files elsewhere got me thinking - rummaging round a bit more, there were quite a few old apache modules and php related stuff which hadn't been caught by the rebuilds, so I deleted all the apache and php directories and re-emerged both. 

Hey presto - working apache+php!

Now I just have to remember what I started doing two weeks ago which triggered this whole saga...

Thanks for the help!

Rich

----------

