[php-src] Issue #8113: Php crashing with a TypeError even when declare(strict_types=1) is not set, or even set to strict_types=0

From: Date: Thu, 17 Feb 2022 20:47:45 +0000
Subject: [php-src] Issue #8113: Php crashing with a TypeError even when declare(strict_types=1) is not set, or even set to strict_types=0
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239856@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8113 Author: kladskull ### Description The following code crashes in a fatal error if the socket is in a closed state. I have tried to get the status of the port, but have had no luck. ```php <?php Console::log('Opening a server socket on address: ' . $address . ' port: ' . $port); $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1); socket_set_nonblock($sock); socket_bind($sock, $address, $port); socket_listen($sock, 100); ... $read = $clients; $write = null; $except = null; // Set up a blocking call to socket_select try { $reads = @socket_select($read, $write, $except, 0, 250000); } catch (Exception) { } ``` Resulted in this output: ``` PHP Fatal error: Uncaught TypeError: socket_select(): Argument #1 ($read) contains a closed socket in /home/ubuntu/xeros/src/Node.php:78 Stack trace: #0 /home/ubuntu/xeros/src/Node.php(78): socket_select() #1 /home/ubuntu/xeros/bin/xero(63): Xeros\Node->listen() #2 {main} thrown in /home/ubuntu/xeros/src/Node.php on line 78 ``` But I expected this output instead: ``` No Fatal Type error.. ``` ### PHP Version PHP 8.1.2 ### Operating System Ubuntu 20.04

« previous php.bugs (#239856) next »