[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream_select does not abort upon exception or empty valid fd set #9590

Closed
bwoebi opened this issue Sep 21, 2022 · 1 comment · Fixed by #9602
Closed

stream_select does not abort upon exception or empty valid fd set #9590

bwoebi opened this issue Sep 21, 2022 · 1 comment · Fixed by #9602

Comments

@bwoebi
Copy link
Member
bwoebi commented Sep 21, 2022

Description

The following code:

<?php

$fds = [];
for ($i = 0; $i < 1023; $i++) {
    $fds[] = fopen("/tmp/__0_a_evil_tmpfile.$i", 'w');
}

list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);

$r = [$a];
$w = $e = [];
var_dump(stream_select($r, $w, $e, PHP_INT_MAX));

Will result in a hang, after printing the warning, with an empty select() syscall being emitted.

However, adding in an error handler throwing an exception, e.g. set_error_handler(function() { throw new \Exception; }); at the start will cause the warning not be printed and still hang indefinitely, hiding the issue very well.

(Original bug report at amphp/amp#398)

PHP Version

PHP 7.4 - master

Operating System

No response

@bwoebi bwoebi changed the title stream_select does not abort upon exception and empty valid fd set stream_select does not abort upon exception or empty valid fd set Sep 21, 2022
@arnaud-lb
Copy link
Member

Fixed in #9602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@arnaud-lb @iluuu1994 @bwoebi and others