|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36016 [PATCH] realpath cache memleaks
Submitted: 2006-01-14 23:54 UTC Modified: 2006-01-16 10:18 UTC
From: Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2006-01-14 (CVS) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2006-01-14 23:54 UTC]
the new realpath cache has a memleak when opening many files.

Reproduce code:

foreach(range('a','z') as $f) {
	foreach(range('a','z') as $g) {
		$file = $f.$g;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-15 02:24 UTC]
Dmitry, please take a look at it.

==1216== 4032 bytes in 42 blocks are definitely lost in loss record 1 of 1
==1216==    at 0x1B9008A9: malloc (vg_replace_malloc.c:149)
==1216==    by 0x813977C: realpath_cache_add (tsrm_virtual_cwd.c:330)
==1216==    by 0x8138BD1: virtual_file_ex (tsrm_virtual_cwd.c:616)
==1216==    by 0x8140D14: expand_filepath (fopen_wrappers.c:529)
==1216==    by 0x8153BDF: _php_stream_fopen (plain_wrapper.c:855)
==1216==    by 0x8153F5C: php_plain_files_stream_opener (plain_wrapper.c:941)
==1216==    by 0x814F5A8: _php_stream_open_wrapper_ex (streams.c:1771)
==1216==    by 0x80DF196: zif_file_get_contents (file.c:530)
==1216==    by 0x819D1A3: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:192)
==1216==    by 0x819FEE9: ZEND_DO_FCALL_SPEC_CONST_HANDLER (zend_vm_execute.h:1587)
==1216==    by 0x819CE50: execute (zend_vm_execute.h:92)
==1216==    by 0x818026B: zend_execute_scripts (zend.c:1101)
==1216==    by 0x813C5BB: php_execute_script (main.c:1720)
==1216==    by 0x81E37D1: main (php_cli.c:1081)

 [2006-01-15 02:33 UTC]
And remove those ifdefs finally. :)
 [2006-01-15 14:53 UTC]
OK, found the problem: it was loosing the cache buckets while transversing the hash list.
simpl patch:
it also adds some comments, which can be useful to readers ;)
 [2006-01-16 10:18 UTC]
Fixed in CVS HEAD and PHP_5_1.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 13 02:01:23 2021 UTC