View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001881 | Xdebug | Installation | public | 2020-11-05 16:13 | 2020-11-05 16:25 |
Reporter | rjung | Assigned To | derick | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | feedback | Resolution | open | ||
Product Version | 3.0.0beta1 | ||||
Summary | 0001881: Unterminated loop during unit test | ||||
Description | The DebugClient class tests/debugger/dbgp/dbgpclient.php contains a do-while read loop in function doRead(). When the script debugged in the PHP child process terminates due to an error, this is not detected and the following call to doRead() will loop unterminated. Observed on Solaris. The first attempt to read() from the socket after the child script error results on a ECONNRESET and all following ones simply will read zero bytes. I scripted a workaround but it is not particularly elegent: --- tests/debugger/dbgp/dbgpclient.php 2020-09-28 12:24:43.000000000 +0000 +++ tests/debugger/dbgp/dbgpclient.php 2020-11-05 17:11:34.378662701 +0000 @@ -8,6 +8,7 @@ protected $port = 0; private $tmpDir; + private $closed = false; public function getPort() { @@ -123,9 +124,31 @@ { $end = false; } + if ( preg_match( '@<error code=@', $read ) ) + { + $end = true; + fclose( $conn ); + $this->closed = true; + } } while( !$end ); } + function close( $echo, $conn, $socket, $ppipes, $php ) + { + if ( $echo ) + { + echo "Connection unexpectedly closed\n"; + echo @file_get_contents( $this->tmpDir . '/php-stdout.txt' ), "\n"; + echo @file_get_contents( $this->tmpDir . '/php-stderr.txt' ), "\n"; + echo @file_get_contents( $this->tmpDir . '/error-output.txt' ), "\n"; + echo @file_get_contents( $this->tmpDir . '/remote_log.txt' ), "\n"; + } + fclose( $socket ); + fclose( $ppipes[0] ); + fclose( $ppipes[1] ); + proc_close( $php ); + } + function runTest( $filename, array $commands, array $ini_options = null ) { $filename = realpath( $filename ); @@ -144,16 +167,17 @@ if ( $conn === false ) { - echo @file_get_contents( $this->tmpDir . '/php-stdout.txt' ), "\n"; - echo @file_get_contents( $this->tmpDir . '/php-stderr.txt' ), "\n"; - echo @file_get_contents( $this->tmpDir . '/error-output.txt' ), "\n"; - echo @file_get_contents( $this->tmpDir . '/remote_log.txt' ), "\n"; - proc_close( $php ); + $this->close(true, $conn, $socket, $ppipes, $php ); return; } // read header $this->doRead( $conn ); + if ( $this->closed ) + { + $this->close(true, $conn, $socket, $ppipes, $php ); + return; + } foreach ( $commands as $command ) { // inject identifier @@ -174,14 +198,15 @@ fwrite( $conn, $command . "\0" ); $this->doRead( $conn ); + if ( $this->closed ) + { + $this->close(true, $conn, $socket, $ppipes, $php ); + return; + } $i++; } - fclose( $conn ); - fclose( $ppipes[0] ); - fclose( $ppipes[1] ); - fclose( $socket ); - proc_close( $php ); + $this->close(false, $conn, $socket, $ppipes, $php); // echo @file_get_contents( $this->tmpDir . '/php-stderr.txt' ), "\n"; // echo @file_get_contents( $this->tmpDir . '/error-output.txt' ), "\n"; | ||||
Tags | test | ||||
Operating System | |||||
PHP Version | 8.0-dev | ||||