Bug #80723 [NEW]: Different sockets compare as equal (regression in 8.0)
From: bugs-a17 at moonlit-rail dot com
Operating system: Linux
PHP version: 8.0.2
Package: Sockets related
Bug Type: Bug
Bug description:Different sockets compare as equal (regression in 8.0)
Description:
------------
In PHP 8.0, two different sockets compare as equal.
This is a regression versus PHP 7.x.
I use PHP for writing internet servers, and upgrading to 8.0 sees most
of them failing. Simple constructs such as, $socknum =
array_search($sock, $sockets)
no longer function as they intuitively ought to.
As an aside, it used to be convenient to do, $array[(int)$socket] =
$socket;
But in 8.0, (int) $socket bombs, and var_export($socket, true) returns
the same value regardless of what's in the socket.
Test script:
---------------
#!/usr/bin/php
<?php
$socket_1 = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$socket_2 = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$vector = array(1 => $socket_1,
2 => $socket_2);
$IDX_1 = array_search($socket_1, $vector);
$IDX_2 = array_search($socket_2, $vector);
$V = substr(PHP_VERSION, 0, 3);
echo "In PHP {$V}:\n".
"\tSocket 1 was found at array index {$IDX_1}, and\n".
"\tSocket 2 was found at array index {$IDX_2}.\n";
socket_close($socket_1);
socket_close($socket_2);
?>
Expected result:
----------------
~$ /tmp/socket-compare-test.php
In PHP 7.3:
Socket 1 was found at array index 1, and
Socket 2 was found at array index 2.
Actual result:
--------------
~$ /tmp/socket-compare-test.php
In PHP 8.0:
Socket 1 was found at array index 1, and
Socket 2 was found at array index 1.
--
Edit bug report at https://bugs.php.net/bug.php?id=80723&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80723&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80723&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80723&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80723&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80723&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80723&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80723&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80723&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80723&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80723&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80723&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80723&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80723&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80723&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80723&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80723&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80723&r=mysqlcfg
Thread (6 messages)
- bugs-a17 at moonlit-rail dot com