Bug #69109 [NEW]: Unable to create any stream after reaching PHP_INT_MAX number of resources

From: Date: Mon, 23 Feb 2015 17:02:59 +0000
Subject: Bug #69109 [NEW]: Unable to create any stream after reaching PHP_INT_MAX number of resources
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190914@lists.php.net to get a copy of this message
From: grzegorz129 at gmail dot com Operating system: Linux PHP version: 5.6.6 Package: Streams related Bug Type: Bug Bug description:Unable to create any stream after reaching PHP_INT_MAX number of resources Description: ------------ PHP assigns unique number for every resource created. Number are unique for application lifetime (they aren't reused even after resource is gone). After creating around 2147483647 resources without terminating application, every function returning stream or maybe even resource (tested on fopen() & stream_socket_accept() w/ TCP server) stops working and begins returning "resource(2147483647) of type (Unknown)". Due to test duration (2h using fopen() and 30h using TCP sockets) it was performed on 32-bit Linux (Debian Jessie) only. It probably affects 64-bit as well as other OSs. Test script: --------------- <?php /* Tested under x86 CLI, configuration: --disable-cgi --without-kerberos --disable-bcmath --with-bz2=/usr --disable-calendar --without-curl --disable-dba --disable-exif --disable-ftp --without-gd --without-gettext --without-gmp --without-iconv --without-imap --without-ldap --without-mcrypt --without-mssql --without-mysql --without-mysqli --without-adabas --without-ibm-db2 --without-iodbc --disable-pcntl --disable-pdo --without-pgsql --without-libedit --without-readline --disable-soap --without-xmlrpc --without-openssl --without-zlib --disable-ctype --disable-xml --disable-filter --disable-json --disable-dom --disable-libxml --disable-mbstring --disable-mbregex --disable-simplexml --disable-hash --without-bz2 --disable-all --without-pear --enable-cli --enable-sockets --enable-debug */ while(true) { $clt = fopen("/dev/null", "w"); //Also tested with stream_socket_accept($server) $cltInt = (int)$clt; var_dump($clt, $cltInt); fclose($clt); } Actual result: -------------- resource(5) of type (stream) int(5) (...) resource(2147483647) of type (Unknown) int(2147483647) Warning: fclose(): 2147483647 is not a valid stream resource in /root/stream_bug.php on line 11 -- Edit bug report at https://bugs.php.net/bug.php?id=69109&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69109&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69109&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69109&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69109&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69109&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69109&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69109&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69109&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69109&r=support Expected behavior: https://bugs.php.net/fix.php?id=69109&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69109&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69109&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69109&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69109&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69109&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69109&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69109&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69109&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69109&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69109&r=mysqlcfg

« previous php.bugs (#190914) next »