Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57817 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99090 invoked from network); 13 Feb 2012 08:56:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Feb 2012 08:56:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=yoram.b@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yoram.b@zend.com; 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: yoram.b@zend.com X-Host-Fingerprint: 212.199.177.89 il-mr1.zend.com Received: from [212.199.177.89] ([212.199.177.89:40596] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/31-27081-D20D83F4 for ; Mon, 13 Feb 2012 03:56:14 -0500 Received: from il-gw1.zend.com (unknown [10.1.1.22]) by il-mr1.zend.com (Postfix) with ESMTP id 5B234607C2 for ; Mon, 13 Feb 2012 10:54:36 +0200 (IST) Received: from mandor.localnet (10.1.3.58) by il-ex2.zend.net (10.1.1.22) with Microsoft SMTP Server (TLS) id 14.1.255.0; Mon, 13 Feb 2012 10:55:59 +0200 To: Dmitry Stogov Date: Mon, 13 Feb 2012 10:56:03 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.37; KDE/4.7.2; i686; ; ) CC: PHP Internals , Alex Haiut , Zeev Suraski , Eran Ifrah , Lior Kaplan References: <201202121409.54891.yoram.b@zend.com> <4F38AE39.8000708@zend.com> In-Reply-To: <4F38AE39.8000708@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-ID: <201202131056.04017.yoram.b@zend.com> X-Originating-IP: [10.1.3.58] Subject: Re: restore user opcode handler in PHP From: yoram.b@zend.com (yoram bar haim) Hi Dmitry. the patch does work, in sense of actually restoring the handlers state when you call zend_set_user_opcode_handler() with original handler. the patch does not solve the basic problem of no re-initialization of static arrayes on mac. As for feeling the array with zero's, if we do that, we also need to fill it with original opcodes, something like : static zend_base_user_opcodes = {0,1,2,3,4,....}; and then in php_module_startup : memset (zend_user_opcode_handlers,0,sizeof(zend_user_opcode_handlers); memcpy (zend_user_opcodes,zend_base_user_opcodes,sizeof(zend_base_user_opcodes); So basically, every modifiably variable should be initialized as startup and not only by static initializer. On Monday, February 13, 2012 08:31:21 AM Dmitry Stogov wrote: > Hi Yoram, > > Can we just fill this arrays with zeros on php startup? > > Thanks. Dmitry. > > On 02/12/2012 04:09 PM, yoram bar haim wrote: > > I first saw this problem while addapting extension to PHP 5.4 but the > > code is the same in 5.3 : > > when you call zend_set_user_opcode_handler() it set's a pointer (handler) > > in zend_user_opcode_handlers and a uint opcode value in > > zend_user_opcodes to ZEND_USER_OPCODE . > > > > you can call zend_set_user_opcode_handler with the original handler to > > restore it, but if the original state did not include ZEND_USER_OPCODE > > you have no way to restore it. > > > > Why restoring ? > > On mac, static variables are not re-initialized on dlclose()+dlopen(). > > that means that apache reload does not re-create > > zend_user_opcode_handlers and zend_user_opcodes. > > if your extension sets user_opcode_handler and is not reloaded in apache > > reload (because you commented it in php.ini, for example), your handlers > > array will actually point to non-exist handler. > > if you will call zend_set_user_opcode_handler() with the original handler > > at MSHUTDOWN, it will restore the handler but zend_user_opcodes[ > will still be ZEND_USER_OPCODE so you will end up calling a NULL > > handler. > > > > we should eather allow zend_set_user_opcode_handler to also set the value > > in zend_user_opcodes[] or we should build those arrayes from > > scratch at php_module_init. > > > > currently an extension tha calls zend_set_user_opcode_handler() will make > > PHP crash on mac after disabling the extension and apache reload.