Re: [PHP-DEV] Zend Engine expert wanted!
At 2:57 AM +0300 6/8/02, Zeev Suraski wrote: We're on the job. I generally think you're right, we have to do some more thinking but chances are we will change the shutdown order to be reversed. Just a FYI, may want to do the same for zend_extension (reverse order). I think that is a zend_llist instead of a zend_hash, but I believe it unloads in the same order they are loaded instead of reverse. Sorry for not ack'ing earlier. No problem, just glad I confirmed the fix. Thanks for help! Cheers, Brian -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
If this is your problem maybe a offical soultion to the problem should be thought. Like in your extension you can define a priority for loading and unloading your extension in the ini. Kinda like init.d. Has there been any discussion about this topic before. - brad --- Brian France [EMAIL PROTECTED] wrote: Zend Engine unloading extension in the wrong order! (Re-post due to no response) I have been tracking down a core dump with my php extension when it is unloading some of its shared libraries. I have shared extension that is link against libexpat and will load fine if it is the only on in the php.ini. If I then load xml.so extension then my extension it works fine, but if it is my extension then xml.so it crashes while xml.so is unloading libexapt. What I have found is the Zend Engine is unloading extension in the same order it loaded them. load: foo_bar.so load: xml.so unload: foo_bar.so unload: xml.so I believe this is wrong and think it should be in reverse order. load: foo_bar.so load: xml.so unload: xml.so unload: foo_bar.so There are two ways to fix this problem. One is to push the modules to the head of the hash, but looking at the zend_hash_add function I decided to go with the second. Second way is to destroy them in reverse order. I created a zend_hash_reverse_destroy and call that instead of zend_hash_destroy. There may be a better way to do this, but this is the quick fix for me. I have included a patch below, should I submit a bug report as well? Thanks, Brian diff -rc php-4.2.1/Zend/zend.c *** php-4.2.1/Zend/zend.c Tue Feb 26 10:59:25 2002 --- php-4.2.1/Zend/zend.c Thu Jun 6 11:32:57 2002 *** *** 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); --- 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_reverse_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); diff -rc php-4.2.1/Zend/zend_hash.c *** php-4.2.1/Zend/zend_hash.c Mon Apr 22 23:53:26 2002 --- php-4.2.1/Zend/zend_hash.c Thu Jun 6 11:32:57 2002 *** *** 550,555 --- 550,579 SET_INCONSISTENT(HT_DESTROYED); } + ZEND_API void zend_hash_reverse_destroy(HashTable *ht) + { + Bucket *p, *q; + + IS_CONSISTENT(ht); + + SET_INCONSISTENT(HT_IS_DESTROYING); + + p = ht-pListTail; + while (p != NULL) { + q = p; + p = p-pLast; + if (ht-pDestructor) { + ht-pDestructor(q-pData); + } + if (!q-pDataPtr q-pData) { + pefree(q-pData, ht-persistent); + } + pefree(q, ht-persistent); + } + pefree(ht-arBuckets, ht-persistent); + + SET_INCONSISTENT(HT_DESTROYED); + } ZEND_API void zend_hash_clean(HashTable *ht) { -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
The issue is *not* the order in which the Zend Engine is loading them in, but the order it is unloading them in. Switching order for loading was a fix that just happened to work. With the patch I provided I can put them in any order and it works. Looking at the Apache source it keeps a list of loaded DSOs and when it loads one pushes it on to the head of the list. This way when it iterates over the list to unload them it is in reverse order than it loaded them. I have been told by a few co-workers that it is industry standard to unload in reverse order that you loaded, but I wanted at least one example so I looked at the Apache source. Shouldn't the Zend Engine always unload extension in reverse order it loaded them in? Thanks! Brian BTW, I think the priority for loading in the ini should be an option, but a completely different subject. At 12:12 PM -0700 6/7/02, brad lafountain wrote: If this is your problem maybe a offical soultion to the problem should be thought. Like in your extension you can define a priority for loading and unloading your extension in the ini. Kinda like init.d. Has there been any discussion about this topic before. - brad --- Brian France [EMAIL PROTECTED] wrote: Zend Engine unloading extension in the wrong order! (Re-post due to no response) I have been tracking down a core dump with my php extension when it is unloading some of its shared libraries. I have shared extension that is link against libexpat and will load fine if it is the only on in the php.ini. If I then load xml.so extension then my extension it works fine, but if it is my extension then xml.so it crashes while xml.so is unloading libexapt. What I have found is the Zend Engine is unloading extension in the same order it loaded them. load: foo_bar.so load: xml.so unload: foo_bar.so unload: xml.so I believe this is wrong and think it should be in reverse order. load: foo_bar.so load: xml.so unload: xml.so unload: foo_bar.so There are two ways to fix this problem. One is to push the modules to the head of the hash, but looking at the zend_hash_add function I decided to go with the second. Second way is to destroy them in reverse order. I created a zend_hash_reverse_destroy and call that instead of zend_hash_destroy. There may be a better way to do this, but this is the quick fix for me. I have included a patch below, should I submit a bug report as well? Thanks, Brian diff -rc php-4.2.1/Zend/zend.c *** php-4.2.1/Zend/zend.c Tue Feb 26 10:59:25 2002 --- php-4.2.1/Zend/zend.c Thu Jun 6 11:32:57 2002 *** *** 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); --- 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_reverse_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); diff -rc php-4.2.1/Zend/zend_hash.c *** php-4.2.1/Zend/zend_hash.c Mon Apr 22 23:53:26 2002 --- php-4.2.1/Zend/zend_hash.c Thu Jun 6 11:32:57 2002 *** *** 550,555 --- 550,579 SET_INCONSISTENT(HT_DESTROYED); } + ZEND_API void zend_hash_reverse_destroy(HashTable *ht) + { + Bucket *p, *q; + + IS_CONSISTENT(ht); + + SET_INCONSISTENT(HT_IS_DESTROYING); + + p = ht-pListTail; + while (p != NULL) { + q = p; + p = p-pLast; + if (ht-pDestructor) { + ht-pDestructor(q-pData); + } + if (!q-pDataPtr q-pData) { + pefree(q-pData, ht-persistent); + } + pefree(q, ht-persistent); + } + pefree(ht-arBuckets, ht-persistent); + + SET_INCONSISTENT(HT_DESTROYED); + } ZEND_API void zend_hash_clean(HashTable *ht) { -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
Can you check and see if using zend_hash_graceful_reverse_destroy() fixes your problem? Andi At 11:44 AM 6/7/2002 -0700, Brian France wrote: Zend Engine unloading extension in the wrong order! (Re-post due to no response) I have been tracking down a core dump with my php extension when it is unloading some of its shared libraries. I have shared extension that is link against libexpat and will load fine if it is the only on in the php.ini. If I then load xml.so extension then my extension it works fine, but if it is my extension then xml.so it crashes while xml.so is unloading libexapt. What I have found is the Zend Engine is unloading extension in the same order it loaded them. load: foo_bar.so load: xml.so unload: foo_bar.so unload: xml.so I believe this is wrong and think it should be in reverse order. load: foo_bar.so load: xml.so unload: xml.so unload: foo_bar.so There are two ways to fix this problem. One is to push the modules to the head of the hash, but looking at the zend_hash_add function I decided to go with the second. Second way is to destroy them in reverse order. I created a zend_hash_reverse_destroy and call that instead of zend_hash_destroy. There may be a better way to do this, but this is the quick fix for me. I have included a patch below, should I submit a bug report as well? Thanks, Brian diff -rc php-4.2.1/Zend/zend.c *** php-4.2.1/Zend/zend.c Tue Feb 26 10:59:25 2002 --- php-4.2.1/Zend/zend.c Thu Jun 6 11:32:57 2002 *** *** 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); --- 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_reverse_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); diff -rc php-4.2.1/Zend/zend_hash.c *** php-4.2.1/Zend/zend_hash.c Mon Apr 22 23:53:26 2002 --- php-4.2.1/Zend/zend_hash.c Thu Jun 6 11:32:57 2002 *** *** 550,555 --- 550,579 SET_INCONSISTENT(HT_DESTROYED); } + ZEND_API void zend_hash_reverse_destroy(HashTable *ht) + { + Bucket *p, *q; + + IS_CONSISTENT(ht); + + SET_INCONSISTENT(HT_IS_DESTROYING); + + p = ht-pListTail; + while (p != NULL) { + q = p; + p = p-pLast; + if (ht-pDestructor) { + ht-pDestructor(q-pData); + } + if (!q-pDataPtr q-pData) { + pefree(q-pData, ht-persistent); + } + pefree(q, ht-persistent); + } + pefree(ht-arBuckets, ht-persistent); + + SET_INCONSISTENT(HT_DESTROYED); + } ZEND_API void zend_hash_clean(HashTable *ht) { -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
I will try that, but I was worried that the pDestructor function would not get called for each item like it was in zend_hash_destroy. Is this the case? Looking at the code what is the difference between zend_hash_graceful_destroy and zend_hash_destroy? Thanks again for the help! Brian At 10:53 PM +0300 6/7/02, Andi Gutmans wrote: Can you check and see if using zend_hash_graceful_reverse_destroy() fixes your problem? Andi At 11:44 AM 6/7/2002 -0700, Brian France wrote: Zend Engine unloading extension in the wrong order! (Re-post due to no response) I have been tracking down a core dump with my php extension when it is unloading some of its shared libraries. I have shared extension that is link against libexpat and will load fine if it is the only on in the php.ini. If I then load xml.so extension then my extension it works fine, but if it is my extension then xml.so it crashes while xml.so is unloading libexapt. What I have found is the Zend Engine is unloading extension in the same order it loaded them. load: foo_bar.so load: xml.so unload: foo_bar.so unload: xml.so I believe this is wrong and think it should be in reverse order. load: foo_bar.so load: xml.so unload: xml.so unload: foo_bar.so There are two ways to fix this problem. One is to push the modules to the head of the hash, but looking at the zend_hash_add function I decided to go with the second. Second way is to destroy them in reverse order. I created a zend_hash_reverse_destroy and call that instead of zend_hash_destroy. There may be a better way to do this, but this is the quick fix for me. I have included a patch below, should I submit a bug report as well? Thanks, Brian diff -rc php-4.2.1/Zend/zend.c *** php-4.2.1/Zend/zend.c Tue Feb 26 10:59:25 2002 --- php-4.2.1/Zend/zend.c Thu Jun 6 11:32:57 2002 *** *** 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); --- 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_reverse_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); diff -rc php-4.2.1/Zend/zend_hash.c *** php-4.2.1/Zend/zend_hash.c Mon Apr 22 23:53:26 2002 --- php-4.2.1/Zend/zend_hash.c Thu Jun 6 11:32:57 2002 *** *** 550,555 --- 550,579 SET_INCONSISTENT(HT_DESTROYED); } + ZEND_API void zend_hash_reverse_destroy(HashTable *ht) + { + Bucket *p, *q; + + IS_CONSISTENT(ht); + + SET_INCONSISTENT(HT_IS_DESTROYING); + + p = ht-pListTail; + while (p != NULL) { + q = p; + p = p-pLast; + if (ht-pDestructor) { + ht-pDestructor(q-pData); + } + if (!q-pDataPtr q-pData) { + pefree(q-pData, ht-persistent); + } + pefree(q, ht-persistent); + } + pefree(ht-arBuckets, ht-persistent); + + SET_INCONSISTENT(HT_DESTROYED); + } ZEND_API void zend_hash_clean(HashTable *ht) { -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
At 01:00 PM 6/7/2002 -0700, Brian France wrote: I will try that, but I was worried that the pDestructor function would not get called for each item like it was in zend_hash_destroy. Is this the case? Looking at the code what is the difference between zend_hash_graceful_destroy and zend_hash_destroy? Yeah the destructor should be called. The graceful_destroy() is just a bit more careful and used when destroying the resource list. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
Yes, zend_hash_graceful_reverse_destroy() fixes the problem as well. Is this a better solution for the fix? Thanks, Brian At 11:06 PM +0300 6/7/02, Andi Gutmans wrote: At 01:00 PM 6/7/2002 -0700, Brian France wrote: I will try that, but I was worried that the pDestructor function would not get called for each item like it was in zend_hash_destroy. Is this the case? Looking at the code what is the difference between zend_hash_graceful_destroy and zend_hash_destroy? Yeah the destructor should be called. The graceful_destroy() is just a bit more careful and used when destroying the resource list. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
At 01:14 PM 6/7/2002 -0700, Brian France wrote: Yes, zend_hash_graceful_reverse_destroy() fixes the problem as well. Is this a better solution for the fix? It's the same but doesn't require a new function. Andi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Zend Engine expert wanted!!!!
Brian, We're on the job. I generally think you're right, we have to do some more thinking but chances are we will change the shutdown order to be reversed. Sorry for not ack'ing earlier. Zeev At 09:44 PM 6/7/2002, Brian France wrote: Zend Engine unloading extension in the wrong order! (Re-post due to no response) I have been tracking down a core dump with my php extension when it is unloading some of its shared libraries. I have shared extension that is link against libexpat and will load fine if it is the only on in the php.ini. If I then load xml.so extension then my extension it works fine, but if it is my extension then xml.so it crashes while xml.so is unloading libexapt. What I have found is the Zend Engine is unloading extension in the same order it loaded them. load: foo_bar.so load: xml.so unload: foo_bar.so unload: xml.so I believe this is wrong and think it should be in reverse order. load: foo_bar.so load: xml.so unload: xml.so unload: foo_bar.so There are two ways to fix this problem. One is to push the modules to the head of the hash, but looking at the zend_hash_add function I decided to go with the second. Second way is to destroy them in reverse order. I created a zend_hash_reverse_destroy and call that instead of zend_hash_destroy. There may be a better way to do this, but this is the quick fix for me. I have included a patch below, should I submit a bug report as well? Thanks, Brian diff -rc php-4.2.1/Zend/zend.c *** php-4.2.1/Zend/zend.c Tue Feb 26 10:59:25 2002 --- php-4.2.1/Zend/zend.c Thu Jun 6 11:32:57 2002 *** *** 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); --- 487,493 zend_destroy_rsrc_list(EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); ! zend_hash_reverse_destroy(module_registry); zend_hash_destroy(GLOBAL_FUNCTION_TABLE); free(GLOBAL_FUNCTION_TABLE); zend_hash_destroy(GLOBAL_CLASS_TABLE); diff -rc php-4.2.1/Zend/zend_hash.c *** php-4.2.1/Zend/zend_hash.c Mon Apr 22 23:53:26 2002 --- php-4.2.1/Zend/zend_hash.c Thu Jun 6 11:32:57 2002 *** *** 550,555 --- 550,579 SET_INCONSISTENT(HT_DESTROYED); } + ZEND_API void zend_hash_reverse_destroy(HashTable *ht) + { + Bucket *p, *q; + + IS_CONSISTENT(ht); + + SET_INCONSISTENT(HT_IS_DESTROYING); + + p = ht-pListTail; + while (p != NULL) { + q = p; + p = p-pLast; + if (ht-pDestructor) { + ht-pDestructor(q-pData); + } + if (!q-pDataPtr q-pData) { + pefree(q-pData, ht-persistent); + } + pefree(q, ht-persistent); + } + pefree(ht-arBuckets, ht-persistent); + + SET_INCONSISTENT(HT_DESTROYED); + } ZEND_API void zend_hash_clean(HashTable *ht) { -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php