Bug #74095 [Fbk->NoF]: Using flush() while php://input is open causes PHP to hang

From: Date: Sun, 24 Jun 2018 04:25:28 +0000
Subject: Bug #74095 [Fbk->NoF]: Using flush() while php://input is open causes PHP to hang
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215913@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74095&edit=1 ID: 74095 Updated by: php-bugs@lists.php.net Reported by: viskoo at gmail dot com Summary: Using flush() while php://input is open causes PHP to hang -Status: Feedback +Status: No Feedback Type: Bug Package: Output Control Operating System: Linux PHP Version: 7.1.1 Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2018-06-14 11:12:36] mike@php.net Cannot reproduce on 7.2 with nginx+fpm nor apache2+mod_php. ------------------------------------------------------------------------ [2017-02-14 14:21:55] viskoo at gmail dot com Forgot to include the command to test: curl -XPUT --data-binary @some_large_file.txt http://localhost:1234/ ------------------------------------------------------------------------ [2017-02-14 14:13:29] viskoo at gmail dot com Description: ------------ If you open stdin, to read the body of a PUT request, echo some strings, and then use flush() to flush the output buffer, PHP will hang after reading 192 kbytes from the input stream, on the next flush() call. This only happens if it's the stdin stream that is open, and not with any other (eg. random local file) stream, and it always happens after reading 48 * 4096 bytes. You will need a web server (I tested with nginx) configured, to test this. Test script: --------------- <?php $file = 'php://input'; $stream = fopen($file, 'r'); fopen($file, 'rb'); header('X-Accel-Buffering: no'); // tell nginx not to buffer $count = 0; while ($chunk = fread($stream, 4096)) { $count++; echo "Read some chunks: $count\n"; flush(); // this is the call that hangs, if you remove this, the script runs fine } echo("Script finished"); Expected result: ---------------- Read some chunks: 1 Read some chunks: 2 Read some chunks: 3 Read some chunks: 4 .... Script finished Actual result: -------------- Read some chunks: 1 Read some chunks: 2 Read some chunks: 3 Read some chunks: 4 .... Read some chunks: 48 *hangs until timeout* ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74095&edit=1

« previous php.bugs (#215913) next »