Re: new/different problem in shutdown

From: Date: Fri, 06 Jul 2001 14:31:38 +0000
Subject: Re: new/different problem in shutdown
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-59091@lists.php.net to get a copy of this message
On Fri, Jul 06, 2001 at 05:12:07PM +0300, Andi Gutmans wrote: > Thies, > > I have thought about your problem. Your patch fixed your test case but it > won't fix all test cases. It is pretty much impossible to make sure on > bailout (including exit() and errors) that all of the reference counts of > the variables will go down to 0 even if we clean the call stack. This is > due to necessary internal locking of variables in Zend. i don't understand why we cant go thru the call-stack and del-ref all the arguments? we're shutting down anyhow - right? also i'm *not talking* about bail at all - bail dosn't work anyhow - and there's no good way to fix it IMHO. but what needs to work is calling exit() from a function if there are resources somewhere on the stack. > I think we need to think of a better way to handle resource shutdowns > (maybe with priorities). this will be major headache, right? don't get me wrong, but i need this to get fixed elsewise using refcounts for dependicies is simply not working and i would have to think of something different - which would be a real shame. tc > > Andi > > At 01:17 PM 7/5/2001 +0200, Thies C. Arntzen wrote: > > 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: php-dev-unsubscribe@lists.php.net > >> For additional commands, e-mail: php-dev-help@lists.php.net > >> To contact the list administrators, e-mail: php-list-admin@lists.php.net > >> >

« previous php.dev (#59091) next »