|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62972 APC 3.1.12 with apc.filters segfauls massively
Submitted: 2012-08-29 20:45 UTC Modified: 2012-08-30 08:17 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bof at bof dot de Assigned: ab (profile)
Status: Closed Package: APC (PECL)
PHP Version: Irrelevant OS: openSUSE 11.4 64bit
Private report: No CVE-ID: None
 [2012-08-29 20:45 UTC] bof at bof dot de
(mistakenly reported on bug 62515, but not related, as I now see)

I encounter this problem with APC-3.1.12 on openSUSE 11.4 64bit, PHP 5.3.15 from 
OBS. Apache 2.2.17 from openSUSE 11.4 base, prefork.

As soon as I activate apc.filters and run some requests - requesing apc.php 
itself suffices, I see segfauls, and regularly glibc double-free reports as 
shown below (abbreviated).

APC-3.1.11 worked fine when trying, so I compared, and found the added pefree 
calls in apc.c apc_regex_destroy_array() to be the cause of the problem.

The attached patch reverts that function to the APC-3.1.11 state.

If I'm not mistaken, the problem stems from the fact that the PHP pcre library 
internally caches all compiled regexpen, returning the cached regexp whenever 
the same string is requested again.

APC compiles the same regexp source anew for each request. But PHP pcre returns 
the internally cached compiled regex. When it is destroyed at request exit time,  
by these pefree calls (really direct free()), the PHP pcre cache does not take 
notice. At the next request in the same process APC receives the already freed 
compiled regex pointer, which is already a problem with arbitrary consequences, 
but then at second-request-exit frees it again -> double free from glibc.

Test script:
Not applicable / happens with any script called multiple times in the described setup

Expected result:
No segfaults

Actual result:
[Wed Aug 29 21:00:52 2012] [notice] child pid 24852 exit signal Aborted (6)
*** glibc detected *** /usr/sbin/httpd2-prefork: double free or corruption 
(!prev): 0x00007f75673324f0 ***
======= Backtrace: =========


apc-3.1.12-regex-no-pefree.patch (last revision 2012-08-29 20:46 UTC by bof at bof dot de)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-29 21:45 UTC]
Automatic comment from SVN on behalf of ab
Log: deactivate this piece of code as suggested in bug #62972, more tests to go
 [2012-08-30 08:17 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2012-08-30 08:17 UTC]
seems the codes has already be reverted by ab :) close this
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jun 28 18:05:44 2022 UTC