php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56467 Memory leaks in current cvs version
Submitted: 2005-07-26 08:34 UTC Modified: 2006-07-27 11:28 UTC
From: ihanic at yahoo dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5_0 CVS-2005-07-26 (dev) OS: Gentoo Base System version 1.4.1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-07-26 08:34 UTC] ihanic at yahoo dot com
Description:
------------
Some memory leaks can be detected if php compiled with --enable debug.

Configure Command =>  './configure' '--prefix=/usr' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--with-apxs2=/usr/sbin/apxs2' '--with-curl=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-tiff-dir=/usr' '--with-config-file-path=/etc/php' '--with-gd' '--with-ttf' '--enable-gd-native-ttf' '--with-freetype-dir=/usr' '--with-zlib-dir=/usr/lib' '--with-mysql=/usr' '--enable-debug' '--enable-track-vars' '--enable-wddx' '--enable-sysvsem' '--enable-sysvshm' '--enable-ftp' '--disable-ipv6' '--enable-trans-sid' '--enable-sockets' '--enable-pcntl' '--with-iconv' '--with-oci8-instant-client' '--with-imap=/usr' '--with-imap-ssl=/usr' '--enable-memory-limit'

apache2 -V
Server version: Apache/2.0.54
Server built:   May  4 2005 17:34:56
Server's Module Magic Number: 20020903:9
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/conf/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/conf/apache2.conf"


Reproduce code:
---------------
cat /var/www/html/bug1194383.php
<?php
class bar{var $f=0;}
class newbar extends bar {}

class foo1234 { public function bar341() { return (1); } }
$sample = new foo1234;
print $sample->bar341();
?>

ab2 -n 2 http://localhost/bug1194383.php

Expected result:
----------------
clear apache error log

Actual result:
--------------
cat error_log
/home/ihanic/cvs/pecl/apc/apc_zend.c(34) :  Freeing 0x08254EFC (32 bytes), script=/var/www/html/bug1194383.php
Last leak repeated 34 times
/home/ihanic/cvs/pecl/apc/apc_compile.c(1899) :  Freeing 0x08254D4C (128 bytes), script=/var/www/html/bug1194383.php
/home/ihanic/cvs/pecl/apc/apc_compile.c(1918) :  Freeing 0x08254AB4 (312 bytes), script=/var/www/html/bug1194383.php
Last leak repeated 2 times
=== Total 39 memory leaks detected ===


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-23 11:01 UTC] mike@php.net
Please try the latest package/PHP version and report back if you're still experiencing this issue.
 [2005-10-31 07:14 UTC] ihanic at yahoo dot com
apache-2.0.54(MPM worker) php(CVS PHP_5_1) apc current cvs version

/home/ihanic/cvs/pecl/apc/apc_zend.c(34) :  Freeing 0x083360F0 (32 bytes), script=/var/www/localhost/htdocs/bug1194383.php
Last leak repeated 28 times
/home/ihanic/cvs/pecl/apc/apc_compile.c(1747) :  Freeing 0x08335FE0 (140 bytes), script=/var/www/localhost/htdocs/bug1194383.php
/home/ihanic/cvs/pecl/apc/apc_compile.c(1766) :  Freeing 0x08335D00 (380 bytes), script=/var/www/localhost/htdocs/bug1194383.php
Last leak repeated 2 times
=== Total 33 memory leaks detected ===
/home/ihanic/cvs/pecl/apc/apc_zend.c(34) :  Freeing 0x083346C0 (32 bytes), script=/var/www/localhost/htdocs/bug1194383.php
Last leak repeated 28 times
/home/ihanic/cvs/pecl/apc/apc_compile.c(1747) :  Freeing 0x083345B0 (140 bytes), script=/var/www/localhost/htdocs/bug1194383.php
/home/ihanic/cvs/pecl/apc/apc_compile.c(1766) :  Freeing 0x083342D0 (380 bytes), script=/var/www/localhost/htdocs/bug1194383.php
Last leak repeated 2 times
=== Total 33 memory leaks detected ===
 [2006-01-02 10:35 UTC] gopalv82 at yahoo dot com
Actually, there's an unfree'd alloc for every class being moved out of the cache.

Any advice on how to fix it would be useful (or whether that pointer can live in heap).
 [2006-07-27 11:28 UTC] gopalv82 at yahoo dot com
To track all the memory allocated for opcodes and to insert hooks to free them after code has run is difficult and a waste of CPU cycles considering the fact that the zend MM automatically cleans up anyway.

Sorry, but to fix these would mean maintaining local state which would just be mere overhead to the operation of APC.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC