|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-08-08 20:37 UTC] trivoallan at clever-age dot com
Description:
------------
Apache version : 2.0.55
Calling set_error_handler from a class constructor makes apache crash.
Calling the function from other methods works without problems.
I've run accross #24708, and the problem does not come from there.
Reproduce code:
---------------
class cbJob
{
public function __construct($id_ressource = null, $action_name = null)
{
set_error_handler(array($this, 'handleError'));
}
public function __destruct()
{
restore_error_handler();
}
}
Expected result:
----------------
Error handler is cbJob::handleError()
Actual result:
--------------
[Tue Aug 08 22:09:49 2006] [notice] child pid 6876 exit signal Segmentation fault (11)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 15:00:02 2025 UTC |
I found the source of the problem while reviewing the handleError method code (thanks for the pointer :). There was a missing break in the switch statement. Should it segfault anyway ? Here's the uncorrected code for the handleError method : function handleRuntimeError($errno, $errstr, $errfile = null, $errline = null, $errcontext = array() ) { $error_types = array ( E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERRROR => 'Catchable Fatal Error' ); $msg = sprintf('%s : "%s" occured in %s on line %d', $error_types[$errno], $errstr, $errfile, $errline); switch($errno) { // A notice cannot fail the job case E_NOTICE: $this->setFailureMessage($msg); default: $this->errorOccured($msg, $this->getMaxTries()); } }