Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57576 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23718 invoked from network); 30 Jan 2012 15:42:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2012 15:42:18 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.199.177.89 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 212.199.177.89 il-mr1.zend.com Received: from [212.199.177.89] ([212.199.177.89:58074] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 75/C7-53934-85AB62F4 for ; Mon, 30 Jan 2012 10:42:17 -0500 Received: from il-gw1.zend.com (unknown [10.1.1.22]) by il-mr1.zend.com (Postfix) with ESMTP id 8DD79607F6; Mon, 30 Jan 2012 17:40:41 +0200 (IST) Received: from tpl2.home (10.1.10.8) by il-ex2.zend.net (10.1.1.22) with Microsoft SMTP Server id 14.1.255.0; Mon, 30 Jan 2012 17:41:34 +0200 Message-ID: <4F26BA53.7040004@zend.com> Date: Mon, 30 Jan 2012 19:42:11 +0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: yoram bar haim , CC: PHP Internals References: <201201301729.12063.yoram.b@zend.com> In-Reply-To: <201201301729.12063.yoram.b@zend.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.1.10.8] Subject: Re: [PHP-DEV] Re: One more critical problem in 5.4 From: dmitry@zend.com (Dmitry Stogov) Hi Mike, I confirm the bug. In case of empty output HTTP headers are sent to stdout or stderr instead of FastCGI stream. To reproduce I configured nginx to use PHP FastCGI server on UNIX socket, then launched (sapi/cgi/php-cgi -b /tmp/fcgi-php5) and performed several request to empty PHP file. The HTTP headers were printed in console running PHP. [dmitry@tpl2 CGI-DEBUG]$ sapi/cgi/php-cgi -b /tmp/fcgi-php5 X-Powered-By: PHP/5.4.0RC7-dev Content-type: text/html X-Powered-By: PHP/5.4.0RC7-dev Content-type: text/html I afraid Yoram's patch is too radical and may have side effects. Mike, could you please think about a safer way of fixing. Thanks. Dmitry. On 01/30/2012 07:29 PM, yoram bar haim wrote: > I Debugged the issue described here by lior. > the problem is : > in php_request_shutdown() we call > sapi_send_headers() after > php_output_deactivate(). > > at this point, > in main/output.c, > OG(flags)& PHP_OUTPUT_ACTIVATED is false so > php_output_write_unbuffered() calls > php_output_stderr() instead of > sapi_module handler. > > the following patch solves the issue but It might be a wrong solution (because > other thins are dependent on this order) so I'm not suggesting it as fix. > > --- main/main.c.orig 2012-01-30 17:25:44.000000000 +0200 > +++ main/main.c 2012-01-30 17:09:05.000000000 +0200 > @@ -1738,12 +1738,13 @@ > } else { > php_output_end_all(TSRMLS_C); > } > + sapi_send_headers(TSRMLS_C); > php_output_deactivate(TSRMLS_C); > } zend_end_try(); > > /* 4. Send the set HTTP headers (note: This must be done AFTER > php_output_discard_all() / php_output_end_all() !!) */ > zend_try { > - sapi_send_headers(TSRMLS_C); > +/* sapi_send_headers(TSRMLS_C); */ > } zend_end_try(); > > /* 5. Reset max_execution_time (no longer executing php code after > response sent) */ >