|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-11-04 09:58 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2021-11-04 09:58 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 06:00:01 2025 UTC |
Description: ------------ Running provided test script (error reporting cannot be Off) on real webserver (Apache, nginx tested) using php-fpm, ends prematurely. This is FPM specific bug (e.g. use of Apache handler is OK). Script "terminates" because FPM sometimes generates empty (zero length) FCGI record / packet. FCGI specification however states that such a record may indicate content termination. Solution is to replace this code in fastcgi.c } else if (len - limit < (int)(sizeof(req->out_buf) - sizeof(fcgi_header))) { if (!req->out_hdr) { open_packet(req, type); } if (limit > 0) { memcpy(req->out_pos, str, limit); req->out_pos += limit; } if (!fcgi_flush(req, 0)) { with this } else if (len - limit < (int)(sizeof(req->out_buf) - sizeof(fcgi_header))) { if (limit > 0) { if (!req->out_hdr) { open_packet(req, type); } memcpy(req->out_pos, str, limit); req->out_pos += limit; } if (!fcgi_flush(req, 0)) { It solves bug, occurring when stream changes (from OUT to ERR or vice versa), but having too few bytes left in output buffer (in this case, first it is called close_packet due to stream change and since limit==0 additional open_packet and close_packet (inside fcgi_flush) is called with zero content length, which webserver interprets as "request finished"). Script has to be tested on real webserver (FPM tester used in .phpt does not copy webserver behavior that well in this case). Every PHP version is affected. If you have any questions, or trouble reproducing bug, please contact me. Test script: --------------- <?php for($i=0;$i<167;$i++){ error_log('PHP is the best programming language'); } echo 'end'; ?> Expected result: ---------------- string "end" Actual result: -------------- empty string