Compdigitec Labs

« | Home | »

Solving “Fatal error: Exception thrown without a stack frame in Unknown on line 0”

By admin | August 2, 2009

If you attempt to throw an exception from a PHP destructor or an PHP exception handler, your script will execute fine for the most part and then crash with the rather cryptic error message, “Fatal error: Exception thrown without a stack frame in Unknown on line 0“. This message is unfortunately very cryptic if you are trying to debug your code. This effect is further amplified due to a lack of PHP debuggers and you must instead resort to using various print_r()s and var_dump()s in order to debug the program. The error message in basic form means that you’ve thrown an exception where an exception cannot be thrown (leading to “no stack frame” – exception handlers and destructors do not have a stack frame. This instead results in this rather cryptic error message that does not include script locations or detailed error information).

Most often, the error will appear if you use an exception handler combined with an error reporting to exception handler by converting it to an ErrorException, then there a suddenly a whole new magnitude of ways to throw errors within the exception handle, especially if E_NOTICE, E_STRICT and/or E_WARNING errors are converted. This form most often occurs when you use variables without first initializing them. This error may be preventable by wrapping the exception handler within a try/catch block.

A second form of this error occurs when you attempt to throw an exception in a destructor. This is well documented in the PHP manual, but this can still be triggered if you accidentally throw an exception:

There is no exactly solid way to identify this type of error as you may not know exactly what your functions do. If you are throwing exceptions manually in your destructor, you need to go back to the PHP manually and read that it is not possible to throw exceptions within the destructor (as it lacks a stack frame). For the other two, you may need to comment out your destructors and manually uncomment parts until you reach the point where you find the error line as the error message produced by PHP is not too informative.

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: PHP | 52 Comments »

52 Responses to “Solving “Fatal error: Exception thrown without a stack frame in Unknown on line 0””

  1. Escortsdehradun Says:
    June 22nd, 2022 at 07:42

    very like perusing an article that can make individuals think

  2. Do My Math Homework Online Says:
    June 30th, 2022 at 06:45

    Struggling with a math’s homework in college, students wonder how will do my math homework online in a days of back to back classes, assignments and quiz may leave you depleted of motivation to tackle yet another math homework and so you can find if someone can do my math homework. The good news is that there are online resources like domyhomework.us where you can find experts and professionals to do your math homework.

Comments