php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36205 Memory leaks with 5.1.2
Submitted: 2006-01-30 11:23 UTC Modified: 2006-02-13 13:20 UTC
From: alain dot russell at blackpepper dot co dot nz Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1.2 OS: Mac OSX Server
Private report: No CVE-ID: None
 [2006-01-30 11:23 UTC] alain dot russell at blackpepper dot co dot nz
Description:
------------
Since upgrading to 5.1.2 I am seeing a lot of memory leak 
errors.

Reproduce code:
---------------
n/a ?

Expected result:
----------------
No memory leak warnings.

Actual result:
--------------
Example errors as follows:
[Mon Jan 30 22:22:16 2006]  Script:  '/Library/WebServer/
Documents/cohesion/itcintl.co.nz/index.php'
/Users/admin/Desktop/php-5.1.2/main/php_variables.c(186) :  
Freeing 0x005F6548 (16 bytes), script=/Library/WebServer/
Documents/cohesion/itcintl.co.nz/index.php
Last leak repeated 2 times
[Mon Jan 30 22:22:16 2006]  Script:  '/Library/WebServer/
Documents/cohesion/itcintl.co.nz/index.php'
/Users/admin/Desktop/php-5.1.2/ext/standard/string.c(3006) :  
Freeing 0x005B1E28 (5 bytes), script=/Library/WebServer/
Documents/cohesion/itcintl.co.nz/index.php
/Users/admin/Desktop/php-5.1.2/Zend/zend_alloc.c(237) : 
Actual location (location was relayed)
Last leak repeated 2 times
=== Total 6 memory leaks detected ===
[Mon Jan 30 22:43:49 2006]  Script:  '/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php'
/Users/admin/Desktop/php-5.1.2/ext/standard/string.c(3006) :  
Freeing 0x005D5448 (9 bytes), script=/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php
/Users/admin/Desktop/php-5.1.2/Zend/zend_alloc.c(237) : 
Actual location (location was relayed)
[Mon Jan 30 22:43:49 2006]  Script:  '/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php'
/Users/admin/Desktop/php-5.1.2/main/php_variables.c(186) :  
Freeing 0x005F4798 (16 bytes), script=/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php
=== Total 2 memory leaks detected ===
[Mon Jan 30 22:44:07 2006]  Script:  '/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php'
/Users/admin/Desktop/php-5.1.2/ext/standard/string.c(3006) :  
Freeing 0x005B1E28 (9 bytes), script=/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php
/Users/admin/Desktop/php-5.1.2/Zend/zend_alloc.c(237) : 
Actual location (location was relayed)
[Mon Jan 30 22:44:07 2006]  Script:  '/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php'
/Users/admin/Desktop/php-5.1.2/main/php_variables.c(186) :  
Freeing 0x005EED98 (16 bytes), script=/Library/WebServer/
Documents/blackpepper/sportzone.co.nz/index.php
=== Total 2 memory leaks detected ===

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-02 11:04 UTC] alain dot russell at blackpepper dot co dot nz
Ok .. I've spent a couple of hours summarising the page to 
see if I can supply code for you here and havent had much 
luck.

Any idea what I should be looking for in the code ?
Do the files listed help track down what I should be looking 
for ?

/php-5.1.2/ext/standard/string.c(3006)
/php-5.1.2/Zend/zend_alloc.c(237)
/php-5.1.2/main/php_variables.c(186)

Thanks
Alain
 [2006-02-02 12:23 UTC] tony2001@php.net
No, the files listed do not help to track it down.
You can try to compile PHP with --disable-zend-memory-manager and see if valgrind can add some more info, but I suspect that there are no valgrind for your platform.
Try to reproduce it on an Intel-based server and see if you can get more info with valgrind. 
But still a short reproduce code would be even more appreciated. 
 [2006-02-09 09:08 UTC] alain dot russell at blackpepper dot co dot nz
I've managed to track the leak down to the following section 
of code .. just load this into a page and refresh it a few 
times to see the leak. It also will not work if it in the 
root of the virtual host - eg: /leak.php it will not leak, /
leak/leak.php and it will .. 

$gb_loggedin = false;
if (isset($storeuser_id)){
	//cookie is available
	if ($storeuser_id != "") {
		$gb_loggedin = true;
		//reset cookie just to make sure.
		setcookie ("storeuser_id", $storeuser_id,time()
+31536000);
	}
}

Let me know if this helps.
Alain
 [2006-02-09 09:10 UTC] alain dot russell at blackpepper dot co dot nz
sorry .. quick note - the server this runs on has 
register_globals on .. (I know, we're working on it:p)
 [2006-02-13 13:20 UTC] dmitry@php.net
Fixed in CVS HEAD, PHP_5_1, PHP_5_0 and PHP_4_4.

The reason of the leaks were duplicate cookies.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC