php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36477 Exceptions break debug_backtrace()
Submitted: 2006-02-21 16:02 UTC Modified: 2006-03-03 11:57 UTC
From: ch at westend dot com Assigned: dmitry (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ch at westend dot com
New email:
PHP Version: OS:

 

 [2006-02-21 16:02 UTC] ch at westend dot com
Description:
------------
After calling "throw new Exception(..)" and entering the
function registered with "set_exception_handler()" the 
debug_backtrace() output is empty.

This is very inconvinient for self written error handling functions as "trigger_error()" for example works fine for debug_backtrace.

I'm aware that the exception itself contains a stack trace
but is there really a reason to empty debug_backtrace()?


Reproduce code:
---------------
<?php

function exception_handler($e) { debug_print_backtrace(); }

function c() { throw new Exception("Problem!"); }
function b() { c(); }
function a() { b(); }

set_exception_handler('exception_handler');
a();

?>


Expected result:
----------------
Backtrace with
#1 exception_handler from c()
#2 c() from b()
#3 b() from a()
#4 a() from main



Actual result:
--------------
#0  exception_handler(Exception Object ([] => Problem!,[] => ,[] => 0,[] => /home/ch/tt.php,[] => 5,[] => Array ([0] => Array ([file] => /home/ch/tt.php,[line] => 6,[function] => c,[args] => Array ()),[1] => Array ([file] => /home/ch/tt.php,[line] => 7,[function] => b,[args] => Array ()),[2] => Array ([file] => /home/ch/tt.php,[line] => 10,[function] => a,[args] => Array ())))) called at [(null):0]


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-03 11:57 UTC] dmitry@php.net
This is not a bug.

In your example, "exception_handler" is called not during exception throwing, but during processing of uncought exception. So the backtrace information is proper.

you can use Exception::getTraceAsString().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Sep 27 22:01:26 2024 UTC