php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64064 Multiple missing checks for memory allocations
Submitted: 2013-01-24 14:24 UTC Modified: 2013-02-18 23:15 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: iliya at polihronov dot com Assigned: gopalv (profile)
Status: Closed Package: APC (PECL)
PHP Version: 5.4.11 OS: Linux
Private report: No CVE-ID: None
 [2013-01-24 14:24 UTC] iliya at polihronov dot com
Description:
------------
We're running APC with tens of thousands of files, tens of millions of blogs 
(WordPress.com) and use user cache. Once the fragmentation goes up and we fill 
up the allocated memory, we're seeing weird behavior in APC.

One of the worst cases was when in 3.1.14 while copying the literals, this 
allocation fails:

dst->literals = (zend_literal*) apc_pool_alloc(pool, (sizeof(zend_literal) * 
src->last_literal));

which results in a segfault on:

*p = *q;

This basically means that nothing frees the write lock on the cache, the APC 
cache stops working and servers get overloaded over time.
While fixing this, I also added checks/rearranged some code on multiple places 
so hopefully we can reduce the weird bugs. It would be nice if we could get this 
patch committed so we don't have to port it from version to version.


Patches

APC-3.1.14-check-memory-allocations.patch (last revision 2013-02-06 02:33 UTC by iliya at polihronov dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-25 05:39 UTC] gopalv@php.net
-Assigned To: +Assigned To: gopalv
 [2013-02-05 05:38 UTC] gopalv@php.net
I tried to fix the indentation, but I'm sort of running out of time to spare for 
this (& attention).

So, can you update the patch to match the indentation style for APC? (spaces, not 
tabs - it's too late to change it now)?

The patch is clean & good otherwise.
 [2013-02-06 02:34 UTC] iliya at polihronov dot com
Ugh, sorry about that. Updated the patch -- the indentation should be better now. 
Thanks.
 [2013-02-18 23:14 UTC] gopalv@php.net
Automatic comment from SVN on behalf of gopalv
Revision: http://svn.php.net/viewvc/?view=revision&revision=329498
Log: [Bug #64064] Be more thorough about checking allocations in APC.

Patch contributed by iliya
 [2013-02-18 23:15 UTC] gopalv@php.net
-Status: Assigned +Status: Closed
 [2013-02-18 23:15 UTC] gopalv@php.net
Patch committed. 

http://news.php.net/php.pecl.cvs/19411

Thank you for making APC better.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed May 25 23:05:45 2022 UTC