php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58216 APC file pointers build up when Apache restarts
Submitted: 2008-06-03 17:28 UTC Modified: 2008-08-08 19:02 UTC
From: nathanlevingreenhaw at gmail dot com Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5.2.5 OS: Red Hat
Private report: No CVE-ID: None
 [2008-06-03 17:28 UTC] nathanlevingreenhaw at gmail dot com
Description:
------------
This is possibly similar to Bug #13529 (if so, the issue is not resolved with 3.0.19).

PHP verison 5.2.6
Apache version 1.3.41

APC configuration (from phpinfo()):
APC Support 	enabled
Version 	3.0.19
MMAP Support 	Enabled
MMAP File Mask 	no value
Locking type 	File Locks
Revision 	$Revision: 3.154.2.5 $
Build Date 	May 29 2008 06:23:14

When I start Apache, I see that there are 7 APC file pointers:

# lsof -p `ps -e | grep httpd | tail -n 1 | awk '{print $1}'` | grep apc
httpd   11209 www_serv  mem    REG      58,0   808987   752623 /lib/php_apc.so
httpd   11209 www_serv    3u   REG       8,5        0   208445 /tmp/.apc.YIPzXw (deleted)
httpd   11209 www_serv    4u   REG       8,5        0   208446 /tmp/.apc.hy2eqL (deleted)
httpd   11209 www_serv    5u   REG       8,5        0   209353 /tmp/.apc.ltIKeV (deleted)
httpd   11209 www_serv    6u   REG       8,5        0   211777 /tmp/.apc.GDmUSZ (deleted)
httpd   11209 www_serv    7u   REG       8,5        0   211778 /tmp/.apc.73VVui (deleted)
httpd   11209 www_serv    8u   REG       8,5        0   211779 /tmp/.apc.zxyAle (deleted)
httpd   11209 www_serv    9u   REG       8,5        0   211780 /tmp/.apc.Rn1gOs (deleted)

Then if I restart Apache, there are 10 APC files:

# apachectl restart
# lsof -p `ps -e | grep httpd | tail -n 1 | awk '{print $1}'` | grep apc
httpd   11314 www_serv  mem    REG      58,0   808987   752623 /lib/php_apc.so
httpd   11314 www_serv    3u   REG       8,5        0   208445 /tmp/.apc.9wtmIW (deleted)
httpd   11314 www_serv    4u   REG       8,5        0   208446 /tmp/.apc.0MjtCq (deleted)
httpd   11314 www_serv    5u   REG       8,5        0   209353 /tmp/.apc.ltIKeV (deleted)
httpd   11314 www_serv    6u   REG       8,5        0   211777 /tmp/.apc.GDmUSZ (deleted)
httpd   11314 www_serv    7u   REG       8,5        0   211778 /tmp/.apc.73VVui (deleted)
httpd   11314 www_serv    8u   REG       8,5        0   211779 /tmp/.apc.9TlAwU (deleted)
httpd   11314 www_serv    9u   REG       8,5        0   211780 /tmp/.apc.Rn1gOs (deleted)
httpd   11314 www_serv   10u   REG       8,5        0   211781 /tmp/.apc.bnjIqo (deleted)
httpd   11314 www_serv   11u   REG       8,5        0   211782 /tmp/.apc.GJlQkS (deleted)

Every time Apache is restarted (via 'restart' or 'graceful') Apache accumulates two more APC file pointers. After Apache has accumulated enough file pointers it will crash.

Let me know if I can provide you any other useful information.


Reproduce code:
---------------
#!/bin/bash

echo -n "Start value: "
lsof -p `ps -e | grep httpd | tail -n 1 | awk '{print $1}'` | grep apc | wc -l

apachectl restart 

echo -n "After restart: "
lsof -p `ps -e | grep httpd | tail -n 1 | awk '{print $1}'` | grep apc | wc -l

Expected result:
----------------
The values for each line are the same. Example:

Start value: 8
After restart: 8

Actual result:
--------------
Start value: 8
After restart: 10

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-05 10:54 UTC] gopalv82 at yahoo dot com
No, this is not the same bug.

Btw, are you running php fast-cgi or mod_php?

(thanks for the bug report, these are things which slip by easily)
 [2008-06-05 13:15 UTC] nathanlevingreenhaw at gmail dot com
I am using mod_php.

I /think/ I might have located the problem. I noticed in apc_cache_create() that CREATE_LOCK() could get called twice if NONBLOCKING_LOCK_AVAILABLE is set. So, I changed apc_cache_destroy() to be:

void apc_cache_destroy(apc_cache_t* cache)
{
    //DESTROY_LOCK(cache);
    apc_lck_destroy(cache->header->lock);
#if NONBLOCKING_LOCK_AVAILABLE
    apc_lck_destroy(cache->header->wrlock);
#endif
    apc_efree(cache);
}

and that seems to prevent the extra files from building up.

I do not completely grok everything in the code, so I am not sure if that change is the most appropriate or not.
 [2008-06-05 16:40 UTC] gopalv82 at yahoo dot com
That looks correct.

Good catch! :)
 [2008-06-26 08:00 UTC] gopalv82 at yahoo dot com
http://news.php.net/php.pecl.cvs/10923

patch applied to the -dev 3.1.x branch, please checkout CVS HEAD & test
 [2008-08-08 19:02 UTC] nathanlevingreenhaw at gmail dot com
CVS head looks good. Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 09:01:28 2024 UTC