Search code examples
phpapacheubuntuapc

PHP APC causing Apache to seg fault


First, versions:

Apache 2.2.22
PHP 5.3.10
Ubuntu 12.04 LTS (everything updated)
APC 3.1.7 (installed via APT and not PEAR)

The problem I'm experiencing is that when issuing a graceful restart (sudo service apache2 graceful), PHP has a fatal error which causes Apache to seg fault. This is what I see in /var/log/apache2/error.log:

[Tue Apr 30 11:05:33 2013] [notice] Graceful restart requested, doing restart
PHP Fatal error:  PHP Startup: apc_mmap: mmap failed: in Unknown on line 0
[Tue Apr 30 11:05:34 2013] [notice] seg fault or similar nasty error detected in the parent process

/etc/php5/conf.d/apc.ini only contains the following:

extension=apc.so
apc.shm_size=256M

Linode is my host. I have the 1GB version with a 256MB swap partition, so 256M should be a reasonable value for apc.shm_size (prior to the recent Linode memory upgrade, I only had 512MB of memory, and apc.shm_size was set to 128M).

Here is some general cache information as shown in apc.php:

APC Version 3.1.7
PHP Version 5.3.10-1ubuntu3.6
APC Host    [removed]
Server Software Apache/2.2.22 (Ubuntu)
Shared Memory   1 Segment(s) with 256.0 MBytes
(mmap memory, pthread mutex Locks locking)
Start Time  2013/04/30 11:09:44
Uptime  21 minutes
File Upload Support 1

Here are my runtime settings as shown in apc.php:

apc.cache_by_default    1
apc.canonicalize    1
apc.coredump_unmap  0
apc.enable_cli  0
apc.enabled 1
apc.file_md5    0
apc.file_update_protection  2
apc.filters 
apc.gc_ttl  3600
apc.include_once_override   0
apc.lazy_classes    0
apc.lazy_functions  0
apc.max_file_size   1M
apc.mmap_file_mask  
apc.num_files_hint  1000
apc.preload_path    
apc.report_autofilter   0
apc.rfc1867 0
apc.rfc1867_freq    0
apc.rfc1867_name    APC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_
apc.rfc1867_ttl 3600
apc.serializer  default
apc.shm_segments    1
apc.shm_size    256M
apc.slam_defense    1
apc.stat    1
apc.stat_ctime  0
apc.ttl 0
apc.use_request_time    1
apc.user_entries_hint   4096
apc.user_ttl    0
apc.write_lock  1

I've done a ton of searching around, but I just can't figure out what's causing this. Is this perhaps a PHP or APC or Apache bug? Is there some configuration value I need to add/change?

Thanks for any help!

[edit]
I just tried updating APC (removed it in apt and installed through PECL), but that didn't fix the problem. I still see seg faults with APC 3.1.13.


Solution

  • After looking around, I noticed a troublesome line in /var/log/syslog:

    kernel: apache2[11303]: segfault at ffffffff ip b7647bd8 sp bfe854b0 error 7 in libpthread-2.15.so[b763f000+17000]
    

    After a little Googling, I came across https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1159748, a confirmed bug in the Ubuntu Apache distribution. I'm glad I'm not crazy! If anyone else encounters this, be sure to follow the progress on this bug.