Bug #70417 [Opn->Ana]: \PharData::compress lead to "too many open files"

From: Date: Thu, 03 Sep 2015 12:11:06 +0000
Subject: Bug #70417 [Opn->Ana]: \PharData::compress lead to "too many open files"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195735@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70417&edit=1 ID: 70417 Updated by: cmb@php.net Reported by: r-orlowski at o2 dot pl Summary: \PharData::compress lead to "too many open files" -Status: Open +Status: Analyzed Type: Bug Package: *Compression related Operating System: Ubuntu 14.04 LTS PHP Version: 5.6.12 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Indeed, when Phar::compress() is called a temporary file is opened[1], but not closed[2] on success. [1] <https://github.com/php/php-src/blob/php-5.6.12/ext/phar/phar_object.c#L2255> [2] <https://github.com/php/php-src/blob/php-5.6.12/ext/phar/phar_object.c#L2342> Previous Comments: ------------------------------------------------------------------------ [2015-09-03 10:34:26] r-orlowski at o2 dot pl Description: ------------ I need to archive a lot (>1000 && <2000) of files into plenty small archives (~900) via PHP application. I used PharData class to create archives. During script run I recieved "failed to open dir: Too many open files" error. After debug my whole application I found that calling PharData::compress() open some /tmp file that is never closed. Calling compress() in a loop lead to rising count of open files. Test script: --------------- <?php function archiveDir($archiveName, $dir) { system("lsof -p ".getmypid()." | wc -l"); // on my local host give 72 $arch = new \PharData($archiveName); $arch->buildFromDirectory($dir); system("lsof -p ".getmypid()." | wc -l"); // on my local host give 73 - buildFromDirectory open $dir system("lsof -p ".getmypid()." | grep /tmp/"); // empty result - no /tmp/ files open $arch->compress(\Phar::GZ); system("lsof -p ".getmypid()." | wc -l"); // on my local host give 74 - compress open /tmp/phppI7yJX file } archiveDir("./testArchive.tar", "./"); system("lsof -p ".getmypid()." | wc -l"); // on my local host give 73 - $dir opened by DirectoryIterator (line 7) is closed system("lsof -p ".getmypid()." | grep /tmp/"); // we have still opened /tmp/phppI7yJX file Expected result: ---------------- Last lsof call should return same count of open files as first call of lsof. Actual result: -------------- lsof called after archiveDir() show, that we have one more open file than before archiveDir() call ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70417&edit=1

« previous php.bugs (#195735) next »