Bug #80723 [Com]: Different sockets compare as equal (regression in 8.0)

From: Date: Mon, 08 Feb 2021 06:18:25 +0000
Subject: Bug #80723 [Com]: Different sockets compare as equal (regression in 8.0)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232000@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80723&edit=1 ID: 80723 Comment by: jacquelynpatte19 at gmail dot com Reported by: bugs-a17 at moonlit-rail dot com Summary: Different sockets compare as equal (regression in 8.0) Status: Open Type: Bug Package: Sockets related Operating System: Linux PHP Version: 8.0.2 Block user comment: N Private report: N New Comment: Reach this website to find the Solutions. https://igarageband.org/garageband-for-pc-windows-download/ Previous Comments: ------------------------------------------------------------------------ [2021-02-08 02:57:57] danack@php.net That probably needs to be investigated, but you may be able to use WeakMaps as a better holder for things like this: https://wiki.php.net/rfc/weak_maps which might need to be documented... ------------------------------------------------------------------------ [2021-02-08 02:44:47] bugs-a17 at moonlit-rail dot com 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 this bug report at https://bugs.php.net/bug.php?id=80723&edit=1

« previous php.bugs (#232000) next »