|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60820 User cache corruption: hash keys are lost
Submitted: 2012-01-20 18:40 UTC Modified: 2013-02-18 00:35 UTC
From: Assigned: gopalv (profile)
Status: No Feedback Package: APC (PECL)
PHP Version: 5.4SVN-2012-01-20 (SVN) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2012-01-20 18:40 UTC]
APC: pecl/svn - trunk (Revision 322504)
PHP: 5_4, svn - PHP 5.4.0RC7-dev
Static build: ./configure  --enable-apc --enable-debug --enable-maintainer-zts

The APC user cache returns corrupted hashes. Hash keys are not preserved. arKey is not copied when duplicating a Bucket to be returned to the user. This can be fixed, for example, like this:

nixnutz@linux-0v4u:~/php-src/branches/PHP_5_4/ext/apc> svn diff
Index: apc_compile.c
--- apc_compile.c       (Revision 322504)
+++ apc_compile.c       (Arbeitskopie)
@@ -901,6 +901,7 @@
         } else {
             CHECK((newp = (Bucket*) apc_pmemcpy(curr, (sizeof(Bucket) + curr->nKeyLength), pool TSRMLS_CC)));
             newp->arKey = ((char*)newp) + sizeof(Bucket);
+            memcpy(newp->arKey, curr->arKey, curr->nKeyLength);
         CHECK((newp = (Bucket*) apc_pmemcpy(curr,

Test script:
php -d apc.enable_cli=1 -r '$tmp = array("foo" => "bar"); apc_add("tmp", $tmp); var_dump(apc_fetch("tmp")); '
array(1) {
  string(3) "bar"

Expected result:
(Result with patch)

nixnutz@linux-0v4u:~/php-src/branches/PHP_5_4> sapi/cli/php -d apc.enable_cli=1 -r '$tmp = array("foo" => "bar"); apc_add("tmp", $tmp); var_dump(apc_fetch("tmp")); '
array(1) {
  string(3) "bar"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-21 04:57 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: gopalv
 [2012-01-21 04:57 UTC]
Gopal, can you doublecheck this one?
 [2012-01-23 14:46 UTC]
Automatic comment from SVN on behalf of uw
Log: Make APC storage handler compile against APC trunk from PECL SVN. Note, it will fail until APC bug #60820 is fixed. Also note, that APC ZTS builds on 5.4 seem to be broken currently (bug #60805). In sum: do not use the APC storage handler at the moment.
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 13:04:05 2022 UTC