ID: 47893 Updated by: lbarn...@php.net Reported By: jon at thesquareplanet dot com -Status: Open +Status: Analyzed Bug Type: Reproducible crash Operating System: Debian Lenny PHP Version: 5.2CVS-2009-04-03 (snap) New Comment:
This is reproducible with this script too: <?php stream_set_blocking(STDIN, 0); $str = str_repeat("a", 65535); var_dump($str); ?> This is caused by STDOUT being non-blocking if your shell passes the same descriptor for STDOUT and STDIN (the write fails with EAGAIN and PHP aborts). Running the same script with different STDIN/STDOUT does not reproduce the problem, e.g. php test.php >/dev/null or php test.php </dev/null Previous Comments: ------------------------------------------------------------------------ [2009-04-03 23:18:55] jon at thesquareplanet dot com A discussion of this bug can also be found at: http://www.mail-archive.com/php-gene...@lists.php.net/msg118150.html ------------------------------------------------------------------------ [2009-04-03 23:17:40] jon at thesquareplanet dot com Description: ------------ When setting STDIN to be non-blocking, and then running fread() on it, the cli script suddenly terminates at a seemingly random point during the reading. No error message is given. Seemingly related bugs: http://bugs.php.net/bug.php?id=25616 <-- This is the same bug, but has erroneously been labeled as a dupe of the one below http://bugs.php.net/bug.php?id=25575 <-- This bug describes a somewhat similar, though not nearly identical, problem These bugs are both set as last modified in 2003/2004, but the issue remains unfixed. Reproduce code: --------------- <?php stream_set_blocking(STDIN, FALSE); while (1) { var_dump(fread(STDIN,1)); echo "\n";; } ?> Expected result: ---------------- A never-ending sequence of var_dumps of either an empty string or a typed character Actual result: -------------- The expected output, but only for a short while, and then the script terminates ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47893&edit=1