[PATCH] dl() and shutdown, revisited

From: Date: Mon, 06 Jun 2005 02:04:22 +0000
Subject: [PATCH] dl() and shutdown, revisited
Groups: php.internals 
Request: Send a blank email to internals+get-16397@lists.php.net to get a copy of this message
I just spent the last hour or so tracking down a couple of mysterious 'ht is already destroyed' messages. It turns out that this is caused by zend_clean_module_rsrc_dtors_cb() attempting to apply a callback function to the regular and persistent lists. At the time this is called, those lists have already been destroyed. The attached patch is something of a hack to avoid bailing out in this case. There might be a better way to handle this. The problem only occurs with dl()'d modules that register resources.

Index: Zend/zend_list.c =================================================================== RCS file: /repository/ZendEngine2/zend_list.c,v retrieving revision 1.64 diff -u -p -r1.64 zend_list.c --- Zend/zend_list.c 17 Feb 2004 22:04:05 -0000 1.64 +++ Zend/zend_list.c 6 Jun 2005 01:57:14 -0000 @@ -247,8 +247,12 @@ static int clean_module_resource(zend_rs static int zend_clean_module_rsrc_dtors_cb(zend_rsrc_list_dtors_entry *ld, int *module_number TSRMLS_DC) { if (ld->module_number == *module_number) { - zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC); - zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC); + if (EG(regular_list).nNumOfElements) { + zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC); + } + if (EG(persistent_list).nNumOfElements) { + zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC); + } return 1; } else { return 0;
« previous php.internals (#16397) next »