php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69109 Unable to create any stream after reaching PHP_INT_MAX number of resources
Submitted: 2015-02-23 17:02 UTC Modified: 2021-02-16 14:21 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: grzegorz129 at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Streams related
PHP Version: 5.6.6 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: grzegorz129 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-02-23 17:02 UTC] grzegorz129 at gmail dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-19 12:38 UTC] cmb@php.net
The proper solution for this issue is to replace the still
exisiting resources with objects.
 [2021-02-16 14:21 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-02-16 14:21 UTC] cmb@php.net
This ticket is actually a duplicate of bug #67845.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC