note 102610 deleted from function.debug-backtrace by danbrown

[email protected] Thu, 24 Feb 2011 07:06:12 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: Anonymous 

----

I have posted this in debug_print_backtrace() as well but I thought I would put it here because it applies to both functions really:

Most methods of getting the backtrace and printing are susceptible to a certain runtime flaw.

If the user is able to produce 100+ errors this will throw an error (max reportable error limit size reached) which in turn will throw 100+ errors on each nest of get_args() creating an infinite loop and eventually downing your server.

If you are looking for a simple backtrace that (so far) will not fall to this error then use this:

    foreach(debug_backtrace() as $k=>$v){
    	if($v['function'] == "include" || $v['function'] == "include_once" || $v['function'] == "require_once" || $v['function'] == "require"){
			$backtracel .= "#".$k." ".$v['function']."(".$v['args'][0].") called at [".$v['file'].":".$v['line']."]<br />";
    	}else{
			$backtracel .= "#".$k." ".$v['function']."() called at [".$v['file'].":".$v['line']."]<br />";
		}
    }