|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56215 apc_fetch() memory leak
Submitted: 2004-10-18 10:18 UTC Modified: 2004-10-28 13:42 UTC
From: xuefer at 21cn dot com Assigned: rasmus (profile)
Status: Closed Package: APC (PECL)
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
 [2004-10-18 10:18 UTC] xuefer at 21cn dot com
echo "<pre>":
$k = "a....................................................";
apc_store($k, 1);
for ($i = 0; $i < 10000; $i ++) {

reload the page 2+ times to see the result

i guess it's the key memory leak


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-18 22:29 UTC] xuefer at 21cn dot com
i've move filename from entry to, renamed as identifier
now both file/user have "char *" which have exactly same behavior and function(usage)
then, i merge union struct into key struct(just make it simple)

copy pointer instead of apc_xstrdup in apc_make_*key identifier
but do apc_xstrdup in make_slot, free it in free_slot

everything goes fine, including my APC_USE_INODE seems have no core dump again

the merge of filename&identifyer make it easy to inode free
 [2004-10-26 16:49 UTC]
Can you post a patch,please?
 [2004-10-26 21:22 UTC] xuefer at 21cn dot com
sure, i was hunting for space to upload (with other bug fixed)
apc_cache.c apc_cache.h:
fixed for APC_USE_INODE
the struct of key is changed, maybe u don't agree.
never do strdup for key before insert!(make_slot)
"find" on the cache is more frequent than insert

don't care about builtin_functions

we have 2 locks but why only 1 file used?

mmap depends on shm?
"#ifdef shm_open" works? maybe u can make marco in config.m4

apc_sem.c: remove redefine warnning, maybe wrong fix

apc_shm.c: IPC_PRIVATE of TSRM seems buggy, the 2nd process will not able to create the shm

other changes:
for apc_cache apc_user_cache, don't put it in GLOBALS
some of this patch is posted in another bug report
this time have a new fix:
function rewrite_const_cast
-    zval_dtor(&cur->op1.u.constant);
+    /*zval_dtor(&cur->op1.u.constant);*/
i never used (string)'1' but phpmyadmin do, so i found this corrupt when i test with win32 (which i have installed phpmyadmin)

although i modified constant_fold, it's still not fixed :(
optimizer is written by cute gschlossnagle right? i saw a stantalone-but-very-old version in cvs/pecl  :P
maybe u can have a review on it

any question or complain about the patch is welcome
 [2004-10-26 21:29 UTC] xuefer at 21cn dot com
"fixed" for APC_USE_INODE
should be:
"improved" for APC_USE_INODE

this "const_cast" make phpmyadmin fine
but before "const_cast" fix(and after my other optimizer fix), it's still quite stable
it's used in production server(100MB traffic), only quite a few core dumps(for builtin_function in apc_compile) maybe 1 dump for 4months
i'd suggest make apc.optimizer to NOT EXPERIMENTAL
 [2004-10-27 14:30 UTC]
I can't get to that ftp site.  Could you email me the patches directly?  (
 [2004-10-27 21:48 UTC] xuefer at 21cn dot com
host was down and is up now.
i sent many emails to u but get no reply except the request for confirm. i confirmed it and no response from u(or server)
 [2004-10-28 13:42 UTC]
I have committed a variation of your apc_fetch memory leak fix.  You changed all sorts of other stuff in your supplied patches and we will look at these separately.  One bug per report please.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 11:01:29 2024 UTC