Tuesday, March 10, 2009

One cause of "Fatal error: Exception thrown without a stack frame in Unknown on line 0"

"Fatal error: Exception thrown without a stack frame in Unknown on line 0" can be quite hard to debug.

php -r '
register_shutdown_function("a");
function a() {
$b = new DateTime("02/40/2009");
} '

Results in:
Fatal error: Exception thrown without a stack frame in Unknown on line 0

The problem is that PHP does not allow exceptions to be thrown in a shutdown function or anything called by a shutdown function. Initializing a DateTime object with an invalid date throws an exception, leading issues similar to above.

No comments: