zeev, andi please comment on my attached patch - it fixes my reported problem! have i overlooked something? thanx, tc On Thu, Jul 05, 2001 at 11:35:15AM +0200, Thies C. Arntzen wrote: > > zeev,andi > > i have a problem with the oci-extension - it makes heaviy > usage of ref-counting and creates dependices between resouces > using refcounts. so i depend on a defined shutdown order and > i also depend on the complete symbol-table to be destroyed > before zend_destroy_rsrc_list is called as zend_destroy_rsrc_list > won't work with my dependicies. > > i have created a small testcase that shows my problem without > using the oci extension: > > the problem is that if a function calles exit the argumets > for that function are _not_ destroyed in the shutdown > mechanism of zend - > > > <? > function any($fh) > { > // exit(); // exit in a function is noo good... > } > > $fp = fopen("/tmp/1","r"); > any($fp); > ?> > > if i set a breakpoint in _file_fopen_dtor (whic is the dtor > for all fopen calls) i get these call frames > > _not_ calling exit in any($fh); > > #0 _file_fopen_dtor (rsrc=0x8420554) at >/home/thies/devel/php4/ext/standard/file.c:149 > #1 0x08190cbb in list_entry_destructor (ptr=0x8420554) at >../../php4/Zend/zend_list.c:179 > #2 0x0818e65d in zend_hash_del_key_or_index (ht=0x83ae410, arKey=0x0, nKeyLength=0, >h=1, flag=1) > at ../../php4/Zend/zend_hash.c:543 > #3 0x08190a25 in zend_list_delete (id=1) at ../../php4/Zend/zend_list.c:57 > #4 0x081a5d70 in _zval_dtor (zvalue=0x8420484, __zend_filename=0x830aa40 >"../../php4/Zend/zend_execute_API.c", > __zend_lineno=260) at ../../php4/Zend/zend_variables.c:80 > #5 0x08193742 in _zval_ptr_dtor (zval_ptr=0x84205a0, > __zend_filename=0x8316ce0 "../../php4/Zend/zend_variables.c", __zend_lineno=169) > at ../../php4/Zend/zend_execute_API.c:260 > #6 0x081a5fcb in _zval_ptr_dtor_wrapper (zval_ptr=0x84205a0) at >../../php4/Zend/zend_variables.c:169 > #7 0x0818e789 in zend_hash_destroy (ht=0x83ae2ec) at ../../php4/Zend/zend_hash.c:572 > #8 0x081934f2 in shutdown_executor () at ../../php4/Zend/zend_execute_API.c:164 > #9 0x08195a70 in zend_deactivate () at ../../php4/Zend/zend.c:538 > #10 0x08089af9 in php_request_shutdown (dummy=0x0) at >/home/thies/devel/php4/main/main.c:692 > #11 0x08085bd3 in main (argc=2, argv=0xbffff7a4) at >/home/thies/devel/php4/sapi/cgi/cgi_main.c:790 > #12 0x409e3450 in __libc_start_main () from /lib/libc.so.6 > > as you can see $fp is freed thru the call to > zend_hash_destroy(&EG(symbol_table)); in shutdown_executor. > > > but not so if i'm _calling_ exit in any($fh); > > #0 _file_fopen_dtor (rsrc=0x84205cc) at >/home/thies/devel/php4/ext/standard/file.c:149 > #1 0x08190cbb in list_entry_destructor (ptr=0x84205cc) at >../../php4/Zend/zend_list.c:179 > #2 0x0818ea00 in zend_hash_apply_deleter (ht=0x83ae410, p=0x8420574) at >../../php4/Zend/zend_hash.c:627 > #3 0x0818ebae in zend_hash_graceful_destroy (ht=0x83ae410) at >../../php4/Zend/zend_hash.c:678 > #4 0x08190e13 in zend_destroy_rsrc_list () at ../../php4/Zend/zend_list.c:234 > #5 0x08193591 in shutdown_executor () at ../../php4/Zend/zend_execute_API.c:178 > #6 0x08195a70 in zend_deactivate () at ../../php4/Zend/zend.c:538 > #7 0x08089af9 in php_request_shutdown (dummy=0x0) at >/home/thies/devel/php4/main/main.c:692 > #8 0x08085bd3 in main (argc=2, argv=0xbffff7a4) at >/home/thies/devel/php4/sapi/cgi/cgi_main.c:790 > #9 0x409e3450 in __libc_start_main () from /lib/libc.so.6 > (gdb) r > > as you see the resource is cleaned thru > zend_destroy_rsrc_list which won't work with dependicies. > > again the problem is that the arguments on the stack do _not_ > get cleared if a function calls exit(). > > what can be done? > > tc > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] >
Index: zend_execute_API.c =================================================================== RCS file: /repository/Zend/zend_execute_API.c,v retrieving revision 1.121 diff -u -r1.121 zend_execute_API.c --- zend_execute_API.c 2001/06/21 21:17:10 1.121 +++ zend_execute_API.c 2001/07/05 11:14:36 @@ -28,6 +28,7 @@ #include "zend_ptr_stack.h" #include "zend_constants.h" #include "zend_extensions.h" +#include "zend_variables.h" #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -152,6 +153,13 @@ void shutdown_executor(ELS_D) { + /* pop first two elements - used internally by zend */ + zend_ptr_stack_pop(&EG(argument_stack)); + zend_ptr_stack_pop(&EG(argument_stack)); + + /* clean "rest of stack" */ + zend_ptr_stack_apply(&EG(argument_stack), ZVAL_DESTRUCTOR); + zend_ptr_stack_destroy(&EG(arg_types_stack)); while (EG(symtable_cache_ptr)>=EG(symtable_cache)) { @@ -160,6 +168,7 @@ EG(symtable_cache_ptr)--; } zend_llist_apply(&zend_extensions, (void (*)(void *)) zend_extension_deactivator);
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]