Edit report at http://bugs.php.net/bug.php?id=54866&edit=1
ID: 54866 Updated by: ras...@php.net Reported by: dustin dot ward1 at gmail dot com Summary: incorrect accounting for realpath_cache_size -Status: Open +Status: Closed Type: Bug Package: *Directory/Filesystem functions Operating System: Linux PHP Version: 5.3.6 -Assigned To: +Assigned To: rasmus Block user comment: N Private report: N New Comment: Thank you very much for the concise bug report and clean patch. It has been applied to all active branches. If you come across anything else, please go to http://php.net/svn-php.php to get an SVN account so you can commit the fixes yourself. Previous Comments: ------------------------------------------------------------------------ [2011-05-20 01:10:00] ras...@php.net Automatic comment from SVN on behalf of rasmus Revision: http://svn.php.net/viewvc/?view=revision&revision=311274 Log: Fix bug 54866 ------------------------------------------------------------------------ [2011-05-19 22:04:33] dustin dot ward1 at gmail dot com Description: ------------ When items are removed from the realpath_cache, if the path is the same as the realpath, then the incorrect size is subtracted from realpath_cache_size. This is due to the "realpath_cache_add" function. If the realpath and the path are the same, then an optimization occurs where bucket->realpath is assigned to the same location as bucket->path (so there's no copy being done). The size added to realpath_cache_size takes this into account, but not when removing. This can cause the size to be incorrect and also be negative. I've submitted a patch and some test code. Test script: --------------- <?php // set the ini options to more easily reproduce // realpath_cache_ttl = 1 // realpath_cache_siz = 16K for($i = 0; $i < 5000; $i++) { file_put_contents("/tmp/foo-$i.txt", ""); clearstatcache(true, "/tmp/foo-$i.txt"); echo "$i - stat cache is: ".realpath_cache_size()."\n"; if(realpath_cache_size() < 0) { print "Hit realpath_cache_size bug\n"; break; } } // clean up created files for ($x = 0; $x < $i; $x++) { unlink("/tmp/foo-$x.txt"); } Expected result: ---------------- If bug is present it should output 'Hit realpath_cache_size bug' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54866&edit=1