potential shutdown order issue
| From: | Gregory Beaver | Date: | Mon, 16 Jun 2008 02:55:40 +0000 |
| Subject: | potential shutdown order issue | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-38265@lists.php.net to get a copy of this message | ||
Hi,
I'm getting errors of hashtable already destroyed when running
phpMyAdmin with PHP 5.3, and (of course), thinking this is a phar issue,
I've traced through and found a problem in the shutdown order.
Basically, php_request_shutdown() calls zend_deactivate() which calls
zend_destroy_rsrc_list(&EG(regular_list)). On the next line,
zend_post_deactivate_modules() is called, which steps through the module
list and unloads all the dynamically loaded modules. If one of these
modules (like mysqli) declares a resource type, then in
module_destructor() zend_clean_module_rsrc_dtors() is called, which
calls zend_clean_modules_rsrc_dtors_cb() (zend_list.c:253).
This function then walks over EG(regular_list), which had been
previously destroyed.
I think this issue could be fixed by moving the
zend_destroy_rsrc_list(&EG(regular_list)) call after the module
shutdown. I've attached a patch demonstrating the principle (this fixes
the hashtable destroyed message and I don't get anything bad like a
segfault).
Could someone with more brains double-check this one? I think it can be
reproduced with a debug build using mysqli loaded dynamically and any
script that uses mysqli, but I've only reproduced it with phpMyAdmin.
Thanks,
Greg