Re: restore user opcode handler in PHP
| From: | Dmitry Stogov | Date: | Mon, 13 Feb 2012 06:31:21 +0000 |
| Subject: | Re: restore user opcode handler in PHP | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-57814@lists.php.net to get a copy of this message | ||
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[<opcode] 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[<opcode>] 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.