Re: [PATCH] Raise warning first on "Maximum execution time exceeded"
| From: | Jille Timmermans | Date: | Mon, 22 Mar 2010 17:08:25 +0000 |
| Subject: | Re: [PATCH] Raise warning first on "Maximum execution time exceeded" | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-47462@lists.php.net to get a copy of this message | ||
Op 22-3-2010 17:51, Sufficool, Stanley schreef:
environment, but as-----Original Message----- From: Jille Timmermans [mailto:jille@quis.cx] Sent: Monday, March 22, 2010 9:30 AM To: Sufficool, Stanley Cc: 'PHP Developers Mailing List' Subject: Re: [PHP-DEV] [PATCH] Raise warning first on "Maximum execution time exceeded" Op 22-3-2010 17:14, Sufficool, Stanley schreef:From: Jille Timmermans [mailto:jille@quis.cx] Sent: Monday, March 22, 2010 8:44 AM To: Johannes Schlüter Cc: troels knak-nielsen; PHP Developers Mailing List Subject: Re: [PHP-DEV] [PATCH] Raise warning first on "Maximum execution time exceeded" Op 22-3-2010 16:14, Johannes Schlüter schreef:-----Original Message-----On Mon, 2010-03-22 at 15:51 +0100, troels knak-nielsen wrote:We log all errors that happens in our production
fatal errors can't be handled from within php, we end up
with little
familiarinformation to go on for further debugging. I'm not veryhack thatwith the php internals code, but I managed to throw in aappears to work. In the handler function for timeouts
(zend_timeout),
behavior, which results in a fatal error. This givesI raise a WARNING, sleep for 1 second and then resume normal
userland code 1
sufficient forsecond to log the error somewhere, which should bedebugging.
A one second delay is no option there. And what actually
happens is
that the warning triggers your custom error handler.
After that it
sleeps then it dies.
This also creates a "nice" way to extend the script runtime
after the
timeout occurred. aka. making the timeout useless for many
scenarios
it was meant for.
This could be made configurable. Shared hosting providers probablywant to disable the 'overriding' of the timeout. At my
work; all code
is written by our own developers; so there's no evil in
there ;) (And
it would be usefull to give extra debugging information)
Think outside the engine. The engine dies with a fatal error, set ahandler to run another PHP instance. The engine then passes the error object as serialized argv to the handler. set_fatal_handler("fatal_handler.php"); I don't a practical way to continue script execution in any way without causing some issue. The service provider should be able to kill this with a
custom error
handler set in INI.
fatal_handler="mail_fatal.sh" #Log / mail using our script
fatal_handler="" # (default) - Don't allow user override
#fatal_handler="" # handler undefined / Allow override
You can already do that from the shutdown functions. They runeven after fatal errors. php -r 'register_shutdown_function(function() { echo "bye"; }); ohcrap();' But the most common request is a backtrace; which can not be generated from the shutdown function; neither from an external script. ("Hey! We could use coredumps for this! That allows post-mortem examination by some external error handler!")
But with register_shutdown_function you do not have an error context right? If the user is doing something with the error, they will need the file, line, message, etc... error_get_last();
Also does register_shutdown_function work with max_execution_time, out of memory, compile error, etc...? I'm really thinking that for a complete fatal handler function to work, it needs to execute a known good handler script outside of the offending code. I agree; but I was trying to point out that it doesn't need to be an external handler.
As far as coredumps: Security, where would the file be located? Who on the server would be able to read it? It was a joke ;)-- Jille
-- Jille-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php-- Jillejohannes