#48969 [Tbd]: register_shutdown_function() buggy in combination with set_error_handler()

From: Date: Tue, 21 Jul 2009 13:25:53 +0000
Subject: #48969 [Tbd]: register_shutdown_function() buggy in combination with set_error_handler()
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2525@lists.php.net to get a copy of this message
ID: 48969 User updated by: bschussek at gmail dot com Reported By: bschussek at gmail dot com Status: To be documented Bug Type: Documentation problem Operating System: Linux Ubuntu 9.04 PHP Version: 5.2.10 New Comment: I still don't quite understand this. Shouldn't my above code behave the same way as this code? Code: ----- function shutdown() { var_dump('SHUTDOWN'); } register_shutdown_function('shutdown'); throw new Exception('my exception'); Output: ------- Exception: my exception in ... string(8) "SHUTDOWN" The only code difference is that in the original code the exception was thrown from within the error handler. AND that in the original code the shutdown function was not called. Previous Comments: ------------------------------------------------------------------------ [2009-07-21 12:58:08] jani@php.net This is really documentation issue. You can't call _any_ user callbacks (f.e. using call_user_func() & such) when there are uncaught exceptions. ------------------------------------------------------------------------ [2009-07-21 12:50:35] jani@php.net One more thing: The shutdown func WILL be run. As long as there are no uncaught exceptions left. ------------------------------------------------------------------------ [2009-07-21 12:46:13] jani@php.net See also bug #30266 for which this fix was added. Commit log mentions a possibility of throwing E_FATAL error for this but leaves that to be discussed. I guess it was never discussed. :) ------------------------------------------------------------------------ [2009-07-21 12:43:38] jani@php.net It's not really buggy, you just can't call user functions when there are uncatched exceptions thrown. Comment in sources say it would otherwise cause instable executor. So instead of crashing, it just won't run your function. :) ------------------------------------------------------------------------ [2009-07-20 11:43:33] bschussek at gmail dot com In reply to Jani: Of course fatal errors are fatal, but my registered error handler should run after the warning, BEFORE the fatal error. If you replace the code throw new Exception('my exception'); with trigger_error(...); instead, you will see that the custom error is triggered correctly. The same is not the case for exceptions. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/48969 -- Edit this bug report at http://bugs.php.net/?id=48969&edit=1

« previous php.doc.bugs (#2525) next »