Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13372 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96121 invoked by uid 1010); 18 Oct 2004 09:14:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 96096 invoked from network); 18 Oct 2004 09:14:26 -0000 Received: from unknown (HELO mail.zend.com) (80.74.107.235) by pb1.pair.com with SMTP; 18 Oct 2004 09:14:26 -0000 Received: (qmail 16963 invoked from network); 18 Oct 2004 09:14:22 -0000 Received: from localhost (HELO zeev-notebook.zend.com) (127.0.0.1) by localhost with SMTP; 18 Oct 2004 09:14:22 -0000 Message-ID: <5.1.0.14.2.20041018104130.06e940b0@localhost> X-Sender: zeev@localhost X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Mon, 18 Oct 2004 11:14:20 +0200 To: "Kamesh Jayachandran" Cc: "Kamesh Jayachandran" ,internals@lists.php.net, zeev@php.net,helly@php.net,andi@php.net In-Reply-To: <1098082359.21967.206675358@webmail.messagingengine.com> References: <1097215824.21523.206031834@webmail.messagingengine.com> <1097215824.21523.206031834@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] why to call php_output_activate(TSRMLS_C) from php_module_startup(reposting first time)(bug #30397) From: zeev@zend.com (Zeev Suraski) At 08:52 18/10/2004, Kamesh Jayachandran wrote: >Can someone respoond to this. > >With regards >Kamesh Jayachandran >On Thu, 07 Oct 2004 23:10:24 -0700, "Kamesh Jayachandran" > said: > > Hi All, > > I could see php_output_activate(TSRMLS_C) getting called from > > php_module_startup immedeately after php_output_startup. > > > > Why is this needed? As each SAPI modules call > > php_output_activate(TSRMLS_C) explicitly as a part of request startup. > > > > Why am I concerned about this? > > > > Ans: php_output_activate(TSRMLS_C) sets > > OG(php_body_write) = php_ub_body_write; > > which causes calls to php_printf to use php_ub_body_write which depends > > on SG(request_info) which is null while php_printf is invoked as part of > > apache startup error(Like Invalid extension/ Non existent extension) > > logging. > > > > This causes segmentation fault. > > > > This change seems to have been introduced in version 1.371 of > > main/main.c by Zeev(3 years and 3 months ago). > > The comment says, > > Fix a major thread safety bug in the output mechanism > > @- Fixed a major memory corruption bug in the thread safe version (Zeev) > > Can I remove a call to php_output_activate(TSRMLS_C) from > > php_module_startup? > > Actually this existed beforehand, the change just shifted code around (the point of this commit was actually NOT to call php_output_startup() on every request startup, and it introduced php_output_activate() which is the one being called on every request startup instead). From looking at the source code it appears that the call to php_output_activate() during php_module_startup() was added to keep 'compatibility' with the code prior to this commit. It looks that this commit fixed the main problem but kept a minor one. I *think* it can be safely removed. > > PS:What is the use of display_startup_errors? What does display mean > > with respect to startup as it might not have any associated request > > context? It has to do with errors that happen during request startup (such as file upload related errors) which cannot be trapped in userland. The check currently present php_error_cb() appears to be messy, though - it should probably be fixed to be just: if (PG(display_errors) && module_initialized && (!PG(during_request_startup) || PG(display_startup_errors)) { This messiness may be related to the other issue you mentioned. Zeev