Bug #67845 [Opn->Dup]: Resource ids may overflow when running a daemon or large app
| From: | cmb@php.net | Date: | Wed, 11 Aug 2021 11:53:02 +0000 |
| Subject: | Bug #67845 [Opn->Dup]: Resource ids may overflow when running a daemon or large app | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235759@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67845&edit=1
ID: 67845
Updated by: cmb@php.net
Reported by: blondie101010 at hotmail dot com
Summary: Resource ids may overflow when running a daemon or
large app
-Status: Open
+Status: Duplicate
Type: Bug
Package: Scripting Engine problem
Operating System: Gentoo
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is actually a duplicate of bug #47396.
Previous Comments:
------------------------------------------------------------------------
[2021-07-27 14:04:30] cmb@php.net
This is not particularly related to streams, but rather a general
issue regarding resources.
------------------------------------------------------------------------
[2021-02-16 14:21:42] cmb@php.net
Related To: Bug #69109
------------------------------------------------------------------------
[2015-05-24 22:56:31] nikic@php.net
Related To: Bug #69702
------------------------------------------------------------------------
[2014-08-14 21:02:48] blondie101010 at hotmail dot com
Description:
------------
Working on a socket server, I had wondered what would happen when the resource id would reach 31
bits long, so I used the code below to test it.
Inevitably it failed at 2147483647.
A proactive solution would be for it to wrap once it reaches its limit, of course checking to see if
the resource is already assigned.
An alternative would be to reuse freed resource ids but I can already see many bad programmers who
would be scared by that option.
Test script:
---------------
<?php
for ($i = 0; $i < 5000000000; $i ++)
{
$fp = fopen("/dev/null", "w");
if (($i % 500000) == 0)
{
var_dump($fp);
system("date");
} // if
fclose($fp);
} // for
?>
Expected result:
----------------
Keep running as there are actually no resources in use.
Actual result:
--------------
It starts giving errors when it exceeds 31 bits on my 32 bit system.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67845&edit=1