Bug #78038 [NEW]: Socket_Select fails when resource array contains non-sequential keys
| From: | ogdg at protonmail dot com | Date: | Mon, 20 May 2019 09:27:50 +0000 |
| Subject: | Bug #78038 [NEW]: Socket_Select fails when resource array contains non-sequential keys | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220908@lists.php.net to get a copy of this message | ||
From: ogdg at protonmail dot com
Operating system: Fedora 30
PHP version: 7.3.5
Package: Sockets related
Bug Type: Bug
Bug description:Socket_Select fails when resource array contains non-sequential keys
Description:
------------
This bug occurs in PHP CLI 7.3.5!
When socket connection resources are indexed in an array by
non-sequential numeric keys, socket_select throws a warning and does not
actually accept the array even though it contains valid socket
resources. By manually re-indexing the array to contain sequentially
numbered keys, the problem disappears.
This could a problem with large key values, or non sequential keys, or
both. The problem did not exist in previous versions of PHP, and it is
not valid for socket_select to require arrays that are sequentially
numbered, as there are reasons to index connection arrays by process ID
or some other meaningful number.
Test script:
---------------
# Assume each $connN variable is a valid socket resource
# Note that array keys are INT and not string type
$connections = array(1235 => $conn1, 2084 => $conn2, 3509 => $conn3);
$w = $e = NULL;
$r = $connections;
$check = socket_select($r, $w, $e, 0);
# The ABOVE code fails with bogus warnings in PHP 7.3.5
# The BELOW code works
$w = $e = NULL;
foreach($connections as $v) $r[] = $v;
$check = socket_select($r, $w, $e, 0);
Expected result:
----------------
Expect socket_select to work as intended and return a value for $check
and a modified connection resource array if appropriate.
Actual result:
--------------
Result is two warnings:
socket_select(): supplied argument is not a valid Socket resource
socket_select(): no resource arrays were passed to select
Previous versions of PHP, including PHP 7 did not have this problem.
--
Edit bug report at https://bugs.php.net/bug.php?id=78038&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78038&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78038&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78038&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78038&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78038&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78038&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78038&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78038&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78038&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78038&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78038&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78038&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78038&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78038&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78038&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78038&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78038&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78038&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78038&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78038&r=mysqlcfg