|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2023 The PHP Group
All rights reserved.
Last updated: Tue Oct 03 09:01:25 2023 UTC