Skip to content

Commit d2b1dec

Browse files
frodeborliclaude
andcommitted
Update GH-9590 tests: fixing the fd_bigset limitation, not papering over it
These tests (arnaud-lb, GH-9602/80232de0e4b) verified that stream_select() fails loudly and immediately once any watched descriptor exceeds FD_SETSIZE, instead of silently dropping it from the fd_set and blocking forever on a socket it can no longer see -- that was the real GH-9590 bug: a silently-dropped fd caused an indefinite, unexplained hang. Our fd_bigset removes the cause of that bug on POSIX rather than just detecting it: a descriptor past 1024 is no longer dropped, it's tracked correctly. So the warning path these tests expected is now dead code for this scenario, and running the tests unmodified exposed exactly the failure mode they were designed to prevent: with nothing ever written to the watched socket and no signal to stop it, `stream_select()` now genuinely blocks on the (correctly-registered) high fd for the full PHP_INT_MAX timeout instead of bailing out early, timing out CI after 2 minutes per test on FreeBSD. Updated both to assert the actual guarantee this PR provides: writing to the paired socket and confirming stream_select() correctly reports it as readable even past the old limit, with a finite timeout. Verified manually against the patched build (posix_setrlimit's hard-limit-raise via -1 fails as EPERM in this sandbox, so run-tests.php's own SKIPIF skips them here, but the exact --FILE-- logic was run standalone with an explicit hard limit and produces the new --EXPECT-- exactly). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 9df943c commit d2b1dec

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

‎ext/standard/tests/streams/gh9590-001.phpt‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
--TEST--
2-
Bug GH-9590 001 (stream_select does not abort upon exception or empty valid fd set)
2+
Bug GH-9590 001 (stream_select works correctly, without warning, past the traditional
3+
FD_SETSIZE descriptor limit on platforms where that limit has been lifted)
34
--EXTENSIONS--
45
posix
56
--SKIPIF--
@@ -21,19 +22,17 @@ for ($i = 0; $i < 1023; $i++) {
2122
}
2223

2324
list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
25+
fwrite($b, "x");
2426

2527
$r = [$a];
2628
$w = $e = [];
27-
var_dump(stream_select($r, $w, $e, PHP_INT_MAX));
29+
var_dump(stream_select($r, $w, $e, 30));
30+
var_dump(fread($a, 1));
2831

2932
?>
30-
--EXPECTF--
31-
Warning: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE.
32-
It is set to 1024, but you have descriptors numbered at least as high as %d.
33-
--enable-fd-setsize=%d is recommended, but you may want to set it
34-
to equal the maximum number of open files supported by your system,
35-
in order to avoid seeing this error again at a later date. in %s on line %d
36-
bool(false)
33+
--EXPECT--
34+
int(1)
35+
string(1) "x"
3736
--CLEAN--
3837
<?php
3938
for ($i = 0; $i < 1023; $i++) {

‎ext/standard/tests/streams/gh9590-002.phpt‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
2-
Bug GH-9590 002 (stream_select does not abort upon exception or empty valid fd set)
2+
Bug GH-9590 002 (a custom error handler that turns warnings into exceptions must not be
3+
spuriously triggered by stream_select() past the traditional FD_SETSIZE limit, on
4+
platforms where that limit has been lifted)
35
--EXTENSIONS--
46
posix
57
--SKIPIF--
@@ -21,21 +23,19 @@ for ($i = 0; $i < 1023; $i++) {
2123
}
2224

2325
list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
26+
fwrite($b, "x");
2427

2528
set_error_handler(function($errno, $errstr) { throw new \Exception($errstr); });
2629

2730
$r = [$a];
2831
$w = $e = [];
29-
var_dump(stream_select($r, $w, $e, PHP_INT_MAX));
32+
var_dump(stream_select($r, $w, $e, 30));
33+
var_dump(fread($a, 1));
3034

3135
?>
32-
--EXPECTF--
33-
Fatal error: Uncaught Exception: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE.
34-
It is set to 1024, but you have descriptors numbered at least as high as %d.
35-
--enable-fd-setsize=%d is recommended, but you may want to set it
36-
to equal the maximum number of open files supported by your system,
37-
in order to avoid seeing this error again at a later date. in %s:%d
38-
Stack trace:%a
36+
--EXPECT--
37+
int(1)
38+
string(1) "x"
3939
--CLEAN--
4040
<?php
4141
for ($i = 0; $i < 1023; $i++) {

0 commit comments

Comments
 (0)