# [SOLVED] apache2 segfaults on php -> zlib

## myak

(Really) Long story short: I have apache2 with php installed, I tried running modx on it and apache's error_log tells me that the child process segfaults:

```
[Tue Mar 20 22:51:51 2012] [notice] child pid 31990 exit signal Segmentation fault (11), possible coredump in /tmp/apache-cores/
```

 I think phpmyadmin gives the same results but haven't tried with coredumps. It's random too, the very same page will get served correctly and then after a refresh the process will crash. I enabled core dumps and here's what I get out of gdb /usr/sbin/apache2 core:

```
#0  0x00007f3d654a99b0 in deflateEnd () from /lib64/libz.so.1

(gdb) where

#0  0x00007f3d654a99b0 in deflateEnd () from /lib64/libz.so.1

#1  0x00007f3d61caee92 in ?? () from /usr/lib64/apache2/modules/libphp5.so

#2  0x00007f3d61caeef6 in ?? () from /usr/lib64/apache2/modules/libphp5.so

#3  0x00007f3d61ef0568 in zend_deactivate_modules () from /usr/lib64/apache2/modules/libphp5.so

#4  0x00007f3d61e7fc0a in php_request_shutdown () from /usr/lib64/apache2/modules/libphp5.so

#5  0x00007f3d61fa65e7 in ?? () from /usr/lib64/apache2/modules/libphp5.so

#6  0x000000000043b397 in ap_run_handler ()

#7  0x000000000043b7bc in ap_invoke_handler ()

#8  0x00000000004485a0 in ap_process_request ()

#9  0x00000000004456e0 in ?? ()

#10 0x0000000000441b27 in ap_run_process_connection ()

#11 0x000000000044e06e in ?? ()

#12 0x00007f3d6809cd0c in start_thread () from /lib64/libpthread.so.0

#13 0x00007f3d67bdf8dd in clone () from /lib64/libc.so.6
```

I reemerged zlib and pretty much everything related on the stack trace (php, apache, I even went as far as to reemerge glibc). Nothing helped. 

Possibly relevant:

I updated to php 5.4 from 5.3 today, didn't use it before so can't say if I had issues with it or not.

zlib was installed with static-libs, I reemerged with -static-libs in a quest to solve this.

My CFLAGS aren't aggressive at all: 

```
CFLAGS="-O2 -pipe -march=core2 -fomit-frame-pointer"
```

I am using ~amd64, USE flags here:

```
USE="-ipv6 mmx sse sse2 X aac a52 aalib acl acpi -aim alsa"

USE="$USE kde bash-completion bzip2 -bluetooth branding cairo cddb cdr"

USE="$USE cgi css cups curl cxx java6 java jabber -icq lame ldap lm_sensors"

USE="$USE mp3 -msn mplayer -networkmanager mysql mysqli ncurses nsplugin"

USE="$USE offsensive ogg opengl php pdf plasma qt4 rdesktop samba -scanner"

USE="$USE session sound win32codecs zsh-completion -yahoo ffmpeg"

USE="$USE nvidia semantic-desktop -accessibility -qt3support"

USE="$USE drm jpeg2k icu -perl -gnome upnp -ldap 3dnow 3dnowext mmxext"

USE="$USE -pulseaudio threads theora apache2 php gd truetype zip"

USE="$USE thumbnail fbcondecor git subversion btrfs fat ntfs ebook"

USE="$USE ipod lastfm mp3tunes acct lzma pdo"
```

(Yeah. First Gentoo installation in 5+ years so forgive me ;)

Emerging php with -zlib (and depending) -gd -truetype -exif seems to fix the issue but that's not really something I want. Any ideas as to what might be causing it?

----------

## Mad Merlin

PHP 5.4 is pretty bleeding edge at this point. At this point I would try and see if it happens with 5.3 as well. If not, it's probably a PHP bug that you should report and let the PHP developers handle.

Edit: The backtrace would be much more useful if you built debug symbols (hint: FEATURES=splitdebug).

Edit2: What Apache MPM are you using? If anything other than mod_prefork, try mod_prefork first.

----------

## myak

Switching to 5.3 seems to have fixed the issue, thanks a lot! On the MPM - I don't know honestly.

```
[ebuild   R    ] www-servers/apache-2.2.21-r2  USE="ssl threads -debug -doc -ldap (-selinux) -static -suexec" 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 cgi cgid 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 -proxy_scgi -reqtimeout -substitute -version" APACHE2_MPMS="-event -itk -peruser -prefork -worker" 0 kB
```

Seems as if no MPM was selected so... the default one? Or none? It's just a server for me to play with some CMS solutions, not a production one, I pretty much emerged apache, mysql and php :)

I'm rebuilding apache, php and zlib with splitdebug, I'll report to php guys if the error is still there.

----------

## Mad Merlin

I'm 99.9% sure the default MPM is prefork, so you're good there.

----------

