Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57815 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77043 invoked from network); 13 Feb 2012 06:33:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Feb 2012 06:33:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@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: dmitry@zend.com X-Host-Fingerprint: 212.199.177.89 il-mr1.zend.com Received: from [212.199.177.89] ([212.199.177.89:33851] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/03-53215-3DEA83F4 for ; Mon, 13 Feb 2012 01:33:56 -0500 Received: from il-gw1.zend.com (unknown [10.1.1.22]) by il-mr1.zend.com (Postfix) with ESMTP id E8C5460784; Mon, 13 Feb 2012 08:32:18 +0200 (IST) Received: from tpl2.home (10.1.10.49) by il-ex2.zend.net (10.1.1.22) with Microsoft SMTP Server id 14.1.255.0; Mon, 13 Feb 2012 08:33:42 +0200 Message-ID: <4F38AED2.8000207@zend.com> Date: Mon, 13 Feb 2012 10:33:54 +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: Laruence , PHP Internals , Alex Haiut , Zeev Suraski , Eran Ifrah , Lior Kaplan References: <201202121409.54891.yoram.b@zend.com> <201202121455.44158.yoram.b@zend.com> In-Reply-To: <201202121455.44158.yoram.b@zend.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.1.10.49] Subject: Re: [PHP-DEV] restore user opcode handler in PHP From: dmitry@zend.com (Dmitry Stogov) In case this patch works, I think it's fine to include it. Thanks. Dmitry. On 02/12/2012 04:55 PM, yoram bar haim wrote: > I think the following patch is a better solution, currently trying it : > --- Zend/zend_execute.c.orig 2012-02-12 14:32:07.000000000 +0200 > +++ Zend/zend_execute.c 2012-02-12 14:31:33.000000000 +0200 > @@ -1512,7 +1512,11 @@ > ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, > user_opcode_handler_t handler) > { > if (opcode != ZEND_USER_OPCODE) { > - zend_user_opcodes[opcode] = ZEND_USER_OPCODE; > + if (handler == NULL) { > + zend_user_opcodes[opcode] = opcode; > + } else { > + zend_user_opcodes[opcode] = ZEND_USER_OPCODE; > + } > zend_user_opcode_handlers[opcode] = handler; > return SUCCESS; > } > > > On Sunday, February 12, 2012 02:41:44 PM Laruence wrote: >> Hi: >> could you file a feature req on bugs.php.net? >> >> I think it's okey to add a zend_restore_user_handler . >> >> like: >> >> ZEND_API int zend_restore_user_opcode_handler(zend_uchar opcode) { >> zend_user_opcodes[opcode] = opcode; >> zend_user_opcode_handlers[opcode] = NULL; >> return SUCCESS; >> } >> >> but it still need dmitry to review :) >> >> thanks >> >> On Sun, Feb 12, 2012 at 8: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. >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php