Bug #16149 Updated: Memory leak with refcount limit.

From: Date: Tue, 18 Jun 2002 08:58:35 +0000
Subject: Bug #16149 Updated: Memory leak with refcount limit.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-11071@lists.php.net to get a copy of this message
ID: 16149 Updated by: derick@php.net Reported By: vincent@ecbar.com -Status: Analyzed +Status: Closed Bug Type: Scripting Engine problem Operating System: ANY PHP Version: 4.2.1-dev New Comment: Vincent, if there are furhter comments on this, feel free to reopen this report and add your comments. Derick Previous Comments: ------------------------------------------------------------------------ [2002-03-20 18:40:10] yohgaki@php.net Thanks Zeev. I didn't try to understand the error. I thought we are going to allocate new zval. ------------------------------------------------------------------------ [2002-03-19 14:34:45] vincent@ecbar.com thanks a lot, i think we get into this refcount problem by mistake. infact, we don't need to assign a single variable more than 64k times. we were trying to reproduce a memory leak bug in apache module which only occur when we upgraded to 4.1.2. we are getting core dump or memory leak problem(httpd process won't release the memory until it die) we are not yet able to reproduce it. for eg, one of the interesting case is, everything works fine except when your change a file to not writable and have the following code ... some arrays which use up to 3M .. if ( $fd = fopen($indexfile, "w")) { ... } apache process will not release the used memory anymore. if we change to if ( $fd = @fopen($indexfile, "w")) it works, if the file doesn't exist and the directory isn't writable it will works too anyway, thx for the info. we'll try to reproduce our problem when we have the time. ------------------------------------------------------------------------ [2002-03-19 12:47:34] zeev@php.net Yasuo - what you're seeing is not a leak, but a crash report (it tried to free a block which was already freed). Lots of these double frees are caught by the cache and in debug mode, they are displayed. Vincent - there's no immediate solution to the problem, other than avoiding the use of the same value more than 64K times. Do you really have to assign $file to that many places? If you really do, you can edit Zend/zend.h, look for the line: zend_ushort refcount; change it to: uint refcount; And recompile (make clean; make) ------------------------------------------------------------------------ [2002-03-19 11:07:24] vincent@ecbar.com we are using lots of arrays in php and have to roll back to 4.0.6 as some of our script won't work on 4.1.2. i am not a php core developer, can you provide us further information regarding the refcount problem? ------------------------------------------------------------------------ [2002-03-19 04:36:19] yohgaki@php.net This must be refcount limitation. I see memory leak with 4.2.1-dev and 4.2.0-dev. Scripting engine problem. This problem may be suspended. It's not simple to fix. May be we should let PHP die if refcount reached it's limit. [yohgaki@dev HEAD]$ ./sapi/cli/php <?php $file = "-----"; for ($i = 0; $i<9000 ; $i++) { $result_array["one"][$i] = $file; $result_array["two"][$i] = $file; $result_array["three"][$i] = $file; $result_array["four"][$i] = $file; $result_array["five"][$i] = $file; $result_array["six"][$i] = $file; $result_array["seven"][$i] = $file; $result_array["eight"][$i] = $file; } echo "done<BR>"; ?> done<BR> [Tue Mar 19 18:41:50 2002] Script: '-' --------------------------------------- /home/yohgaki/cvs/php/HEAD/Zend/zend_execute.h(62) : Block 0x082AC068 status: Beginning: Cached (allocated on /home/yohgaki/cvs/php/HEAD/Zend/zend_execute.c:467, 12 bytes) End: OK --------------------------------------- [yohgaki@dev HEAD]$ ./sapi/cli/php -v 4.2.1-dev [yohgaki@dev HEAD]$ ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/16149 -- Edit this bug report at http://bugs.php.net/?id=16149&edit=1

« previous php.bugs (#11071) next »