php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51001 Always shows stack trace when a Fatal error occurs
Submitted: 2010-02-10 20:05 UTC Modified: 2013-02-18 00:34 UTC
Votes:15
Avg. Score:4.7 ± 0.6
Reproduced:15 of 15 (100.0%)
Same Version:6 (40.0%)
Same OS:4 (26.7%)
From: abdallah at gmx dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.3.1 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
1 + 46 = ?
Subscribe to this entry?

 
 [2010-02-10 20:05 UTC] abdallah at gmx dot com
Description:
------------
Always shows stack trace when a Fatal error occurs without having to do always something like this :

<?php
function test() {
    throw new Exception;
}

try {
    test();
} catch(Exception $e) {
    echo $e->getTraceAsString();
}
?>


Reproduce code:
---------------
<?php
function test() {
    throw new Exception;
}

try {
    test();
} catch(Exception $e) {
    echo $e->getTraceAsString();
}
?>

Expected result:
----------------
#0 /home/bjori/tmp/ex.php(7): test()
#1 {main}

Actual result:
--------------
nothin'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-10 01:51 UTC] a at b dot c dot de
An observation from me:

A stack trace is dumped in the event of a fatal error (depending on the error reporting level); but it's only when an uncaught exception reaches the top of the call stack without being handled that such an error occurs. If it is caught, then it's not an uncaught exception and therefore not a Fatal error.
 [2010-11-24 09:44 UTC] jani@php.net
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: Scripting Engine problem
 [2010-11-24 09:44 UTC] jani@php.net
I do get a trace here using your reproduce script with PHP 5.3.4RC1. So what is the problem?
 [2011-04-12 20:40 UTC] dharkness at gmail dot com
You actually have to remove the try/catch to reproduce the problem. When you 
catch the exception, no fatal error is raised and you can see the stack trace. If 
you don't catch the exception, the PHP engine raises an E_FATAL error which 
cannot be trapped.

We use a shutdown hook and check for fatal errors so we can report the issue, but 
at that point there's no stack trace--just the file and line where the error 
occurred. It would be nice to have a similar function to error_get_last() to get 
the stack trace, such as backtrace_get_last().
 [2012-12-05 16:19 UTC] anrdaemon at freemail dot ru
I'm facing a problem in tracking down various issues in a complex project, and I would greatly benefit from ability to call Exception::getTraceAsString() statically.

So that instead of doing something like

      default:
        if(isset($GLOBALS['toolDebugfilterEnabled']) && $GLOBALS['toolDebugfilterEnabled'] === true)
        {
          print('Breakpoint reached in: ');
          $e = new Exception($mode);
          print($e->getTraceAsString());

I could just do a

      default:
        if(isset($GLOBALS['toolDebugfilterEnabled']) && $GLOBALS['toolDebugfilterEnabled'] === true)
        {
          print('Breakpoint reached in: ');
          print(Exception::getTraceAsString());

and be done with it.
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC