stack overflow in long running script. found the problem!

From: Date: Mon, 05 Jul 1999 14:28:12 +0000
Subject: stack overflow in long running script. found the problem!
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-1896@lists.php.net to get a copy of this message
whua.... did some digging: zend_variables.c:85 pushes thingies on the "garbage" stack, which overflows! zend_execute does not call DEC_AI_COUNT() "often" enough! i helped myself by calling sometimg like "DEC_AI_COUNT" in zval_dtor - and it helped! which is what we call a "pfusch" in germany (hack would be a too positive word for this;-) so, please check if you forgot to call DEC_AI_COUNT somewhere BTW: the script in question does something like: $dok = new Dossier; while ($db->getrow()) { $dok->loadFromDB($db->getid()); // loadFromDB is ~300 lines of code! $dok->save(); // ~500 lines of code } so maybe you forget to call your garbage-collector while just beeing in a loop? regards, tc On Mon, 5 Jul 1999, Thies C. Arntzen wrote: > hi, > this could be a tough one: > > a script that runs thru thousands of records (using classses etc) crashes > after some time saying: > > FATAL: erealloc(): Unable to allocate -131072 bytes > FATAL: erealloc(): Unable to allocate 0 bytes > > i traced it down to zend_ptr_stack_push and added a debug line like this: > > if (stack->top > 1000) > fprintf(stderr, "> 0x%08x %d opcode %d on opline %d of %s() at %s:%d\n", > stack, > stack->top - 1, > active_opline->opcode, > active_opline-EG(active_op_array)->opcodes, > get_active_function_name(), > zend_get_executed_filename(ELS_C), > zend_get_executed_lineno(ELS_C)); > > (dunno if the debug-output shows the correct script-line, but...) > > what i get is: > > > ..... > > 0x000e010c 8219 opcode 57 on opline 6 of _gettabletype() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:2368 > > 0x000e010c 8220 opcode 57 on opline 6 of _gettabletype() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:2368 > > 0x000e010c 8221 opcode 57 on opline 2078 of filtabexists() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:1220 > > 0x000e010c 8222 opcode 58 on opline 12 of modify() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:556 > > 0x000e010c 8223 opcode 58 on opline 12 of modify() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:556 > > 0x000e010c 8224 opcode 58 on opline 12 of modify() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:556 > > 0x000e010c 8225 opcode 58 on opline 12 of modify() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:556 > ..... > > 0x000e010c 16399 opcode 57 on opline 48 of _parse() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:1982 > > 0x000e010c 16400 opcode 57 on opline 48 of _parse() at > > ../../php/package/phpbasic/phpsite/functions/dossier.fnc:1982 > > 0x000e010c 16401 opcode 1515870810 on opline -60479576Segmentation fault (core dumped) > > and so on - this stack is never ever popped, which causes the overflow & the crash. > > there's a lot of php code running - if you want i can get you access to one of my boxes! > > regards, > tc > > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" > Digital Collections Phone +49 40 235350 Fax +49 40 23535180 > Hammerbrookstr. 93 20097 Hamburg / Germany > > > -- > PHP 4 Beta > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.version4 (#1896) next »