php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70431 Memory leak in php_ini.c
Submitted: 2015-09-04 20:59 UTC Modified: 2015-09-10 11:26 UTC
From: sixd@php.net Assigned: laruence (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0Git-2015-09-04 (Git) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sixd@php.net
New email:
PHP Version: OS:

 

 [2015-09-04 20:59 UTC] sixd@php.net
Description:
------------
==12787== 51 bytes in 1 blocks are definitely lost in loss record 363 of 675
==12787==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==12787==    by 0x681D37: _estrndup (zend_alloc.c:2516)
==12787==    by 0x64E44D: expand_filepath_with_mode (fopen_wrappers.c:822)
==12787==    by 0x650B8E: php_init_config (php_ini.c:555)
==12787==    by 0x64A5A4: php_module_startup (main.c:2147)
==12787==    by 0x73B3CC: php_cli_startup (php_cli.c:423)
==12787==    by 0x73CEE3: main (php_cli.c:1322)

Fix (from @Senthil) is:

--- php_ini.c.orig	2015-09-05 00:02:16.000000000 +1000
+++ php_ini.c	2015-09-04 23:58:13.000000000 +1000
@@ -600,6 +600,8 @@
 			if (opened_path) {
 				zend_string_release(opened_path);
 			}
+			efree((char*) fh.filename);
+			fh.filename = (char *) NULL;
 			php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
 		}
 	}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-05 03:24 UTC] laruence@php.net
any script to reproduce this?
 [2015-09-08 06:49 UTC] sixd@php.net
From the reporter:
"This issue is reproducible only when run the test through "gmake test TESTS=%" command and with valgrind option "--leak-check=full".
Basically leak occurs while php attempts to load the php config ini file, i.e., before it loads actual testcase.

Please configure the run-tests.php to run Valgrind and make sure add "--leak-check=full" in run-test.php in valgrind command present in line number 1882, 1884.
Then run test in ext/date as follow:
gmake test TESTS=ext/date

Even first testcase ext/date/tests/002.phpt will LEAK with the reported memory leak (definitely lost category)."
 [2015-09-10 11:26 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-09-10 11:56 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a8368ddc38a1940e705914699478dd1f83e745ee
Log: Fixed bug #70431 (Memory leak in php_ini.c)
 [2015-09-10 11:56 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2015-09-15 12:13 UTC] ab@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a8368ddc38a1940e705914699478dd1f83e745ee
Log: Fixed bug #70431 (Memory leak in php_ini.c)
 [2016-07-20 11:36 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a8368ddc38a1940e705914699478dd1f83e745ee
Log: Fixed bug #70431 (Memory leak in php_ini.c)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 03:01:28 2024 UTC