php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67845 Resource ids may overflow when running a daemon or large app
Submitted: 2014-08-14 21:02 UTC Modified: 2021-08-11 11:53 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: blondie101010 at hotmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: Irrelevant OS: Gentoo
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: blondie101010 at hotmail dot com
New email:
PHP Version: OS:

 

 [2014-08-14 21:02 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-27 14:04 UTC] cmb@php.net
-Package: Streams related +Package: Scripting Engine problem
 [2021-07-27 14:04 UTC] cmb@php.net
This is not particularly related to streams, but rather a general
issue regarding resources.
 [2021-08-11 11:53 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-08-11 11:53 UTC] cmb@php.net
This is actually a duplicate of bug #47396.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 16 19:03:35 2021 UTC