Use zend_error_noreturn() for fatal errors

This commit is contained in:
Dmitry Stogov 2015-04-01 13:32:23 +03:00
parent ac470ddf1c
commit acfc31c0f8
18 changed files with 68 additions and 68 deletions

View File

@ -1020,7 +1020,7 @@ ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const ch
*object = this_ptr; *object = this_ptr;
if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce)) { if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce)) {
zend_error(E_CORE_ERROR, "%s::%s() must be derived from %s::%s", zend_error_noreturn(E_CORE_ERROR, "%s::%s() must be derived from %s::%s",
Z_OBJCE_P(this_ptr)->name->val, get_active_function_name(), ce->name->val, get_active_function_name()); Z_OBJCE_P(this_ptr)->name->val, get_active_function_name(), ce->name->val, get_active_function_name());
} }
@ -1057,7 +1057,7 @@ ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this
if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce)) { if (ce && !instanceof_function(Z_OBJCE_P(this_ptr), ce)) {
if (!(flags & ZEND_PARSE_PARAMS_QUIET)) { if (!(flags & ZEND_PARSE_PARAMS_QUIET)) {
zend_error(E_CORE_ERROR, "%s::%s() must be derived from %s::%s", zend_error_noreturn(E_CORE_ERROR, "%s::%s() must be derived from %s::%s",
ce->name->val, get_active_function_name(), Z_OBJCE_P(this_ptr)->name->val, get_active_function_name()); ce->name->val, get_active_function_name(), Z_OBJCE_P(this_ptr)->name->val, get_active_function_name());
} }
va_end(va); va_end(va);
@ -1840,7 +1840,7 @@ ZEND_API int zend_startup_module_ex(zend_module_entry *module) /* {{{ */
if (module->module_startup_func) { if (module->module_startup_func) {
EG(current_module) = module; EG(current_module) = module;
if (module->module_startup_func(module->type, module->module_number)==FAILURE) { if (module->module_startup_func(module->type, module->module_number)==FAILURE) {
zend_error(E_CORE_ERROR,"Unable to start %s module", module->name); zend_error_noreturn(E_CORE_ERROR,"Unable to start %s module", module->name);
EG(current_module) = NULL; EG(current_module) = NULL;
return FAILURE; return FAILURE;
} }
@ -2189,7 +2189,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
if (info->class_name) { if (info->class_name) {
ZEND_ASSERT(info->type_hint == IS_OBJECT); ZEND_ASSERT(info->type_hint == IS_OBJECT);
if (!scope && (!strcasecmp(info->class_name, "self") || !strcasecmp(info->class_name, "parent"))) { if (!scope && (!strcasecmp(info->class_name, "self") || !strcasecmp(info->class_name, "parent"))) {
zend_error(E_CORE_ERROR, "Cannot declare a return type of %s outside of a class scope", info->class_name); zend_error_noreturn(E_CORE_ERROR, "Cannot declare a return type of %s outside of a class scope", info->class_name);
} }
} }
@ -2399,15 +2399,15 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
} }
if (ctor && ctor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && ctor->common.fn_flags & ZEND_ACC_CTOR) { if (ctor && ctor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && ctor->common.fn_flags & ZEND_ACC_CTOR) {
zend_error(E_CORE_ERROR, "Constructor %s::%s() cannot declare a return type", scope->name->val, ctor->common.function_name->val); zend_error_noreturn(E_CORE_ERROR, "Constructor %s::%s() cannot declare a return type", scope->name->val, ctor->common.function_name->val);
} }
if (dtor && dtor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) { if (dtor && dtor->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) {
zend_error(E_CORE_ERROR, "Destructor %s::%s() cannot declare a return type", scope->name->val, dtor->common.function_name->val); zend_error_noreturn(E_CORE_ERROR, "Destructor %s::%s() cannot declare a return type", scope->name->val, dtor->common.function_name->val);
} }
if (clone && clone->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) { if (clone && clone->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && dtor->common.fn_flags & ZEND_ACC_DTOR) {
zend_error(E_CORE_ERROR, "%s::%s() cannot declare a return type", scope->name->val, clone->common.function_name->val); zend_error_noreturn(E_CORE_ERROR, "%s::%s() cannot declare a return type", scope->name->val, clone->common.function_name->val);
} }
efree((char*)lc_class_name); efree((char*)lc_class_name);
} }
@ -3092,7 +3092,7 @@ get_function_via_handler:
zend_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val); zend_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
retval = 0; retval = 0;
} else { } else {
zend_error(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val); zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
} }
} else if (!fcc->object && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { } else if (!fcc->object && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
int severity; int severity;
@ -3636,7 +3636,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
case IS_ARRAY: case IS_ARRAY:
case IS_OBJECT: case IS_OBJECT:
case IS_RESOURCE: case IS_RESOURCE:
zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources"); zend_error_noreturn(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
break; break;
default: default:
break; break;
@ -3798,7 +3798,7 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const
EG(scope) = scope; EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->write_property) { if (!Z_OBJ_HT_P(object)->write_property) {
zend_error(E_CORE_ERROR, "Property %s of class %s cannot be updated", name, Z_OBJCE_P(object)->name->val); zend_error_noreturn(E_CORE_ERROR, "Property %s of class %s cannot be updated", name, Z_OBJCE_P(object)->name->val);
} }
ZVAL_STRINGL(&property, name, name_length); ZVAL_STRINGL(&property, name, name_length);
Z_OBJ_HT_P(object)->write_property(object, &property, value, NULL); Z_OBJ_HT_P(object)->write_property(object, &property, value, NULL);
@ -3976,7 +3976,7 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const c
EG(scope) = scope; EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->read_property) { if (!Z_OBJ_HT_P(object)->read_property) {
zend_error(E_CORE_ERROR, "Property %s of class %s cannot be read", name, Z_OBJCE_P(object)->name->val); zend_error_noreturn(E_CORE_ERROR, "Property %s of class %s cannot be read", name, Z_OBJCE_P(object)->name->val);
} }
ZVAL_STRINGL(&property, name, name_length); ZVAL_STRINGL(&property, name, name_length);

View File

@ -203,7 +203,7 @@ static void zend_ast_add_array_element(zval *result, zval *offset, zval *expr)
zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval(Z_DVAL_P(offset)), expr); zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval(Z_DVAL_P(offset)), expr);
break; break;
default: default:
zend_error(E_ERROR, "Illegal offset type"); zend_error_noreturn(E_ERROR, "Illegal offset type");
break; break;
} }
} }
@ -338,7 +338,7 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
zval_dtor(&op2); zval_dtor(&op2);
break; break;
default: default:
zend_error(E_ERROR, "Unsupported constant expression"); zend_error_noreturn(E_ERROR, "Unsupported constant expression");
} }
} }

View File

@ -1949,7 +1949,7 @@ ZEND_FUNCTION(create_function)
func = zend_hash_str_find_ptr(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1); func = zend_hash_str_find_ptr(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
if (!func) { if (!func) {
zend_error(E_ERROR, "Unexpected inconsistency in create_function()"); zend_error_noreturn(E_ERROR, "Unexpected inconsistency in create_function()");
RETURN_FALSE; RETURN_FALSE;
} }
if (func->refcount) { if (func->refcount) {

View File

@ -269,7 +269,7 @@ static void zend_closure_free_storage(zend_object *object) /* {{{ */
zend_execute_data *ex = EG(current_execute_data); zend_execute_data *ex = EG(current_execute_data);
while (ex) { while (ex) {
if (ex->func == &closure->func) { if (ex->func == &closure->func) {
zend_error(E_ERROR, "Cannot destroy active lambda function"); zend_error_noreturn(E_ERROR, "Cannot destroy active lambda function");
} }
ex = ex->prev_execute_data; ex = ex->prev_execute_data;
} }

View File

@ -4490,7 +4490,7 @@ static void zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_as
if (CG(current_import_function)) { if (CG(current_import_function)) {
zend_string *import_name = zend_hash_find_ptr(CG(current_import_function), lcname); zend_string *import_name = zend_hash_find_ptr(CG(current_import_function), lcname);
if (import_name && !zend_string_equals_ci(lcname, import_name)) { if (import_name && !zend_string_equals_ci(lcname, import_name)) {
zend_error(E_COMPILE_ERROR, "Cannot declare function %s " zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare function %s "
"because the name is already in use", name->val); "because the name is already in use", name->val);
} }
} }
@ -5229,7 +5229,7 @@ void zend_compile_const_decl(zend_ast *ast) /* {{{ */
&& (import_name = zend_hash_find_ptr(CG(current_import_const), name)) && (import_name = zend_hash_find_ptr(CG(current_import_const), name))
) { ) {
if (!zend_string_equals(import_name, name)) { if (!zend_string_equals(import_name, name)) {
zend_error(E_COMPILE_ERROR, "Cannot declare const %s because " zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare const %s because "
"the name is already in use", name->val); "the name is already in use", name->val);
} }
} }
@ -5499,7 +5499,7 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
zend_hash_update(Z_ARRVAL_P(result), STR_EMPTY_ALLOC(), value); zend_hash_update(Z_ARRVAL_P(result), STR_EMPTY_ALLOC(), value);
break; break;
default: default:
zend_error(E_COMPILE_ERROR, "Illegal offset type"); zend_error_noreturn(E_COMPILE_ERROR, "Illegal offset type");
break; break;
} }
} else { } else {

View File

@ -334,14 +334,14 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
if (scope) { if (scope) {
ce = scope; ce = scope;
} else { } else {
zend_error(E_ERROR, "Cannot access self:: when no class scope is active"); zend_error_noreturn(E_ERROR, "Cannot access self:: when no class scope is active");
} }
} else if (class_name_len == sizeof("parent")-1 && } else if (class_name_len == sizeof("parent")-1 &&
!memcmp(lcname, "parent", sizeof("parent")-1)) { !memcmp(lcname, "parent", sizeof("parent")-1)) {
if (!scope) { if (!scope) {
zend_error(E_ERROR, "Cannot access parent:: when no class scope is active"); zend_error_noreturn(E_ERROR, "Cannot access parent:: when no class scope is active");
} else if (!scope->parent) { } else if (!scope->parent) {
zend_error(E_ERROR, "Cannot access parent:: when current class scope has no parent"); zend_error_noreturn(E_ERROR, "Cannot access parent:: when current class scope has no parent");
} else { } else {
ce = scope->parent; ce = scope->parent;
} }
@ -350,7 +350,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
if (EG(current_execute_data) && EG(current_execute_data)->called_scope) { if (EG(current_execute_data) && EG(current_execute_data)->called_scope) {
ce = EG(current_execute_data)->called_scope; ce = EG(current_execute_data)->called_scope;
} else { } else {
zend_error(E_ERROR, "Cannot access static:: when no class scope is active"); zend_error_noreturn(E_ERROR, "Cannot access static:: when no class scope is active");
} }
} else { } else {
ce = zend_fetch_class(class_name, flags); ce = zend_fetch_class(class_name, flags);
@ -360,7 +360,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
ret_constant = zend_hash_find(&ce->constants_table, constant_name); ret_constant = zend_hash_find(&ce->constants_table, constant_name);
if (ret_constant == NULL) { if (ret_constant == NULL) {
if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) { if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
zend_error(E_ERROR, "Undefined class constant '%s::%s'", class_name->val, constant_name->val); zend_error_noreturn(E_ERROR, "Undefined class constant '%s::%s'", class_name->val, constant_name->val);
} }
} else if (Z_ISREF_P(ret_constant)) { } else if (Z_ISREF_P(ret_constant)) {
ret_constant = Z_REFVAL_P(ret_constant); ret_constant = Z_REFVAL_P(ret_constant);

View File

@ -48,7 +48,7 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
} }
ZVAL_OBJ(&tmp, add_previous); ZVAL_OBJ(&tmp, add_previous);
if (!instanceof_function(Z_OBJCE(tmp), base_exception_ce)) { if (!instanceof_function(Z_OBJCE(tmp), base_exception_ce)) {
zend_error(E_ERROR, "Cannot set non exception as previous exception"); zend_error_noreturn(E_ERROR, "Cannot set non exception as previous exception");
return; return;
} }
ZVAL_OBJ(&zv, exception); ZVAL_OBJ(&zv, exception);
@ -116,7 +116,7 @@ ZEND_API void zend_throw_exception_internal(zval *exception) /* {{{ */
if(EG(exception)) { if(EG(exception)) {
zend_exception_error(EG(exception), E_ERROR); zend_exception_error(EG(exception), E_ERROR);
} }
zend_error(E_ERROR, "Exception thrown without a stack frame"); zend_error_noreturn(E_ERROR, "Exception thrown without a stack frame");
} }
if (zend_throw_exception_hook) { if (zend_throw_exception_hook) {
@ -215,7 +215,7 @@ ZEND_METHOD(exception, __construct)
int argc = ZEND_NUM_ARGS(); int argc = ZEND_NUM_ARGS();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SlO!", &message, &code, &previous, base_exception_ce) == FAILURE) { if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SlO!", &message, &code, &previous, base_exception_ce) == FAILURE) {
zend_error(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])"); zend_error_noreturn(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])");
} }
object = getThis(); object = getThis();
@ -245,7 +245,7 @@ ZEND_METHOD(error_exception, __construct)
size_t message_len, filename_len; size_t message_len, filename_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|sllslO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, base_exception_ce) == FAILURE) { if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|sllslO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, base_exception_ce) == FAILURE) {
zend_error(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])"); zend_error_noreturn(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])");
} }
object = getThis(); object = getThis();
@ -972,13 +972,13 @@ ZEND_API void zend_throw_exception_object(zval *exception) /* {{{ */
zend_class_entry *exception_ce; zend_class_entry *exception_ce;
if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) { if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) {
zend_error(E_ERROR, "Need to supply an object when throwing an exception"); zend_error_noreturn(E_ERROR, "Need to supply an object when throwing an exception");
} }
exception_ce = Z_OBJCE_P(exception); exception_ce = Z_OBJCE_P(exception);
if (!exception_ce || !instanceof_function(exception_ce, base_exception_ce)) { if (!exception_ce || !instanceof_function(exception_ce, base_exception_ce)) {
zend_error(E_ERROR, "Exceptions must be valid objects derived from the Exception base class"); zend_error_noreturn(E_ERROR, "Exceptions must be valid objects derived from the Exception base class");
} }
zend_throw_exception_internal(exception); zend_throw_exception_internal(exception);
} }

View File

@ -880,7 +880,7 @@ ZEND_API void zend_verify_internal_return_error(const zend_function *zf, const c
fclass = ""; fclass = "";
} }
zend_error(E_CORE_ERROR, "Return value of %s%s%s() must %s%s, %s%s returned", zend_error_noreturn(E_CORE_ERROR, "Return value of %s%s%s() must %s%s, %s%s returned",
fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind); fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind);
} }

View File

@ -527,7 +527,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
char *colon; char *colon;
if (IS_CONSTANT_VISITED(p)) { if (IS_CONSTANT_VISITED(p)) {
zend_error(E_ERROR, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p)); zend_error_noreturn(E_ERROR, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p));
} else if (Z_TYPE_P(p) == IS_CONSTANT) { } else if (Z_TYPE_P(p) == IS_CONSTANT) {
int refcount; int refcount;
@ -550,7 +550,7 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) { if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) {
size_t len; size_t len;
zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p)); zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
len = Z_STRLEN_P(p) - ((colon - Z_STRVAL_P(p)) + 1); len = Z_STRLEN_P(p) - ((colon - Z_STRVAL_P(p)) + 1);
if (inline_change) { if (inline_change) {
zend_string *tmp = zend_string_init(colon + 1, len, 0); zend_string *tmp = zend_string_init(colon + 1, len, 0);
@ -584,9 +584,9 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
} }
if ((Z_CONST_FLAGS_P(p) & IS_CONSTANT_UNQUALIFIED) == 0) { if ((Z_CONST_FLAGS_P(p) & IS_CONSTANT_UNQUALIFIED) == 0) {
if (save->val[0] == '\\') { if (save->val[0] == '\\') {
zend_error(E_ERROR, "Undefined constant '%s'", save->val + 1); zend_error_noreturn(E_ERROR, "Undefined constant '%s'", save->val + 1);
} else { } else {
zend_error(E_ERROR, "Undefined constant '%s'", save->val); zend_error_noreturn(E_ERROR, "Undefined constant '%s'", save->val);
} }
if (inline_change) { if (inline_change) {
zend_string_release(save); zend_string_release(save);
@ -698,7 +698,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
case sizeof(zend_fcall_info): case sizeof(zend_fcall_info):
break; /* nothing to do currently */ break; /* nothing to do currently */
default: default:
zend_error(E_ERROR, "Corrupted fcall_info provided to zend_call_function()"); zend_error_noreturn(E_ERROR, "Corrupted fcall_info provided to zend_call_function()");
break; break;
} }
@ -1182,7 +1182,7 @@ ZEND_API void zend_timeout(int dummy) /* {{{ */
zend_on_timeout(EG(timeout_seconds)); zend_on_timeout(EG(timeout_seconds));
} }
zend_error(E_ERROR, "Maximum execution time of %pd second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s"); zend_error_noreturn(E_ERROR, "Maximum execution time of %pd second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
} }
/* }}} */ /* }}} */
@ -1224,7 +1224,7 @@ void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
if (!DeleteTimerQueueTimer(NULL, tq_timer, NULL)) { if (!DeleteTimerQueueTimer(NULL, tq_timer, NULL)) {
EG(timed_out) = 0; EG(timed_out) = 0;
tq_timer = NULL; tq_timer = NULL;
zend_error(E_ERROR, "Could not delete queued timer"); zend_error_noreturn(E_ERROR, "Could not delete queued timer");
return; return;
} }
tq_timer = NULL; tq_timer = NULL;
@ -1234,7 +1234,7 @@ void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */
if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)&EG(timed_out), seconds*1000, 0, WT_EXECUTEONLYONCE)) { if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)&EG(timed_out), seconds*1000, 0, WT_EXECUTEONLYONCE)) {
EG(timed_out) = 0; EG(timed_out) = 0;
tq_timer = NULL; tq_timer = NULL;
zend_error(E_ERROR, "Could not queue new timer"); zend_error_noreturn(E_ERROR, "Could not queue new timer");
return; return;
} }
EG(timed_out) = 0; EG(timed_out) = 0;
@ -1283,7 +1283,7 @@ void zend_unset_timeout(void) /* {{{ */
if (!DeleteTimerQueueTimer(NULL, tq_timer, NULL)) { if (!DeleteTimerQueueTimer(NULL, tq_timer, NULL)) {
EG(timed_out) = 0; EG(timed_out) = 0;
tq_timer = NULL; tq_timer = NULL;
zend_error(E_ERROR, "Could not delete queued timer"); zend_error_noreturn(E_ERROR, "Could not delete queued timer");
return; return;
} }
tq_timer = NULL; tq_timer = NULL;
@ -1319,20 +1319,20 @@ check_fetch_type:
switch (fetch_type) { switch (fetch_type) {
case ZEND_FETCH_CLASS_SELF: case ZEND_FETCH_CLASS_SELF:
if (!EG(scope)) { if (!EG(scope)) {
zend_error(E_ERROR, "Cannot access self:: when no class scope is active"); zend_error_noreturn(E_ERROR, "Cannot access self:: when no class scope is active");
} }
return EG(scope); return EG(scope);
case ZEND_FETCH_CLASS_PARENT: case ZEND_FETCH_CLASS_PARENT:
if (!EG(scope)) { if (!EG(scope)) {
zend_error(E_ERROR, "Cannot access parent:: when no class scope is active"); zend_error_noreturn(E_ERROR, "Cannot access parent:: when no class scope is active");
} }
if (!EG(scope)->parent) { if (!EG(scope)->parent) {
zend_error(E_ERROR, "Cannot access parent:: when current class scope has no parent"); zend_error_noreturn(E_ERROR, "Cannot access parent:: when current class scope has no parent");
} }
return EG(scope)->parent; return EG(scope)->parent;
case ZEND_FETCH_CLASS_STATIC: case ZEND_FETCH_CLASS_STATIC:
if (!EG(current_execute_data) || !EG(current_execute_data)->called_scope) { if (!EG(current_execute_data) || !EG(current_execute_data)->called_scope) {
zend_error(E_ERROR, "Cannot access static:: when no class scope is active"); zend_error_noreturn(E_ERROR, "Cannot access static:: when no class scope is active");
} }
return EG(current_execute_data)->called_scope; return EG(current_execute_data)->called_scope;
case ZEND_FETCH_CLASS_AUTO: { case ZEND_FETCH_CLASS_AUTO: {
@ -1348,11 +1348,11 @@ check_fetch_type:
if (use_autoload) { if (use_autoload) {
if (!silent && !EG(exception)) { if (!silent && !EG(exception)) {
if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) { if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {
zend_error(E_ERROR, "Interface '%s' not found", class_name->val); zend_error_noreturn(E_ERROR, "Interface '%s' not found", class_name->val);
} else if (fetch_type == ZEND_FETCH_CLASS_TRAIT) { } else if (fetch_type == ZEND_FETCH_CLASS_TRAIT) {
zend_error(E_ERROR, "Trait '%s' not found", class_name->val); zend_error_noreturn(E_ERROR, "Trait '%s' not found", class_name->val);
} else { } else {
zend_error(E_ERROR, "Class '%s' not found", class_name->val); zend_error_noreturn(E_ERROR, "Class '%s' not found", class_name->val);
} }
} }
} }
@ -1371,11 +1371,11 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *
if (use_autoload) { if (use_autoload) {
if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) { if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) { if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
zend_error(E_ERROR, "Interface '%s' not found", class_name->val); zend_error_noreturn(E_ERROR, "Interface '%s' not found", class_name->val);
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) { } else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
zend_error(E_ERROR, "Trait '%s' not found", class_name->val); zend_error_noreturn(E_ERROR, "Trait '%s' not found", class_name->val);
} else { } else {
zend_error(E_ERROR, "Class '%s' not found", class_name->val); zend_error_noreturn(E_ERROR, "Class '%s' not found", class_name->val);
} }
} }
} }
@ -1432,7 +1432,7 @@ void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
if (ai.cnt) { if (ai.cnt) {
zend_error(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")", zend_error_noreturn(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
ce->name->val, ai.cnt, ce->name->val, ai.cnt,
ai.cnt > 1 ? "s" : "", ai.cnt > 1 ? "s" : "",
DISPLAY_ABSTRACT_FN(0), DISPLAY_ABSTRACT_FN(0),

View File

@ -303,7 +303,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */
} }
if (generator->flags & ZEND_GENERATOR_CURRENTLY_RUNNING) { if (generator->flags & ZEND_GENERATOR_CURRENTLY_RUNNING) {
zend_error(E_ERROR, "Cannot resume an already running generator"); zend_error_noreturn(E_ERROR, "Cannot resume an already running generator");
} }
/* Drop the AT_FIRST_YIELD flag */ /* Drop the AT_FIRST_YIELD flag */

View File

@ -78,7 +78,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun
if (!fn_proxy || !*fn_proxy) { if (!fn_proxy || !*fn_proxy) {
if ((fcic.function_handler = zend_hash_find_ptr(function_table, Z_STR(fci.function_name))) == NULL) { if ((fcic.function_handler = zend_hash_find_ptr(function_table, Z_STR(fci.function_name))) == NULL) {
/* error at c-level */ /* error at c-level */
zend_error(E_CORE_ERROR, "Couldn't find implementation for method %s%s%s", obj_ce ? obj_ce->name->val : "", obj_ce ? "::" : "", function_name); zend_error_noreturn(E_CORE_ERROR, "Couldn't find implementation for method %s%s%s", obj_ce ? obj_ce->name->val : "", obj_ce ? "::" : "", function_name);
} }
if (fn_proxy) { if (fn_proxy) {
*fn_proxy = fcic.function_handler; *fn_proxy = fcic.function_handler;
@ -107,7 +107,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun
obj_ce = object ? Z_OBJCE_P(object) : NULL; obj_ce = object ? Z_OBJCE_P(object) : NULL;
} }
if (!EG(exception)) { if (!EG(exception)) {
zend_error(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? obj_ce->name->val : "", obj_ce ? "::" : "", function_name); zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? obj_ce->name->val : "", obj_ce ? "::" : "", function_name);
} }
} }
/* copy arguments back, they might be changed by references */ /* copy arguments back, they might be changed by references */
@ -259,7 +259,7 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva
zend_user_iterator *iterator; zend_user_iterator *iterator;
if (by_ref) { if (by_ref) {
zend_error(E_ERROR, "An iterator cannot be used with foreach by reference"); zend_error_noreturn(E_ERROR, "An iterator cannot be used with foreach by reference");
} }
iterator = emalloc(sizeof(zend_user_iterator)); iterator = emalloc(sizeof(zend_user_iterator));
@ -312,7 +312,7 @@ static int zend_implement_traversable(zend_class_entry *interface, zend_class_en
return SUCCESS; return SUCCESS;
} }
} }
zend_error(E_CORE_ERROR, "Class %s must implement interface %s as part of either %s or %s", zend_error_noreturn(E_CORE_ERROR, "Class %s must implement interface %s as part of either %s or %s",
class_type->name->val, class_type->name->val,
zend_ce_traversable->name->val, zend_ce_traversable->name->val,
zend_ce_iterator->name->val, zend_ce_iterator->name->val,
@ -336,7 +336,7 @@ static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entr
if (class_type->num_interfaces) { if (class_type->num_interfaces) {
for (i = 0; i < class_type->num_interfaces; i++) { for (i = 0; i < class_type->num_interfaces; i++) {
if (class_type->interfaces[i] == zend_ce_iterator) { if (class_type->interfaces[i] == zend_ce_iterator) {
zend_error(E_ERROR, "Class %s cannot implement both %s and %s at the same time", zend_error_noreturn(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
class_type->name->val, class_type->name->val,
interface->name->val, interface->name->val,
zend_ce_iterator->name->val); zend_ce_iterator->name->val);
@ -368,7 +368,7 @@ static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry
} else { } else {
/* c-level get_iterator cannot be changed */ /* c-level get_iterator cannot be changed */
if (class_type->get_iterator == zend_user_it_get_new_iterator) { if (class_type->get_iterator == zend_user_it_get_new_iterator) {
zend_error(E_ERROR, "Class %s cannot implement both %s and %s at the same time", zend_error_noreturn(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
class_type->name->val, class_type->name->val,
interface->name->val, interface->name->val,
zend_ce_aggregate->name->val); zend_ce_aggregate->name->val);

View File

@ -988,7 +988,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
} }
if (!valid) { if (!valid) {
zend_error(E_COMPILE_ERROR, "Invalid UTF-8 codepoint escape sequence"); zend_error_noreturn(E_COMPILE_ERROR, "Invalid UTF-8 codepoint escape sequence");
} }
errno = 0; errno = 0;

View File

@ -986,7 +986,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
} }
if (!valid) { if (!valid) {
zend_error(E_COMPILE_ERROR, "Invalid UTF-8 codepoint escape sequence"); zend_error_noreturn(E_COMPILE_ERROR, "Invalid UTF-8 codepoint escape sequence");
} }
errno = 0; errno = 0;

View File

@ -42,7 +42,7 @@
#define Z_OBJ_PROTECT_RECURSION(zval_p) \ #define Z_OBJ_PROTECT_RECURSION(zval_p) \
do { \ do { \
if (Z_OBJ_APPLY_COUNT_P(zval_p) >= 3) { \ if (Z_OBJ_APPLY_COUNT_P(zval_p) >= 3) { \
zend_error(E_ERROR, "Nesting level too deep - recursive dependency?"); \ zend_error_noreturn(E_ERROR, "Nesting level too deep - recursive dependency?"); \
} \ } \
Z_OBJ_INC_APPLY_COUNT_P(zval_p); \ Z_OBJ_INC_APPLY_COUNT_P(zval_p); \
} while (0) } while (0)
@ -170,7 +170,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp) /* {{{ *
return ht; return ht;
} }
zend_error(E_ERROR, ZEND_DEBUGINFO_FUNC_NAME "() must return an array"); zend_error_noreturn(E_ERROR, ZEND_DEBUGINFO_FUNC_NAME "() must return an array");
return NULL; /* Compilers are dumb and don't understand that noreturn means that the function does NOT need a return value... */ return NULL; /* Compilers are dumb and don't understand that noreturn means that the function does NOT need a return value... */
} }

View File

@ -117,7 +117,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
old_exception = NULL; old_exception = NULL;
if (EG(exception)) { if (EG(exception)) {
if (EG(exception) == object) { if (EG(exception) == object) {
zend_error(E_ERROR, "Attempt to destruct pending exception"); zend_error_noreturn(E_ERROR, "Attempt to destruct pending exception");
} else { } else {
old_exception = EG(exception); old_exception = EG(exception);
EG(exception) = NULL; EG(exception) = NULL;

View File

@ -214,7 +214,7 @@ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigac
sa.sa_mask = global_sigmask; sa.sa_mask = global_sigmask;
if (sigaction(signo, &sa, NULL) < 0) { if (sigaction(signo, &sa, NULL) < 0) {
zend_error(E_ERROR, "Error installing signal handler for %d", signo); zend_error_noreturn(E_ERROR, "Error installing signal handler for %d", signo);
} }
/* unsure this signal is not blocked */ /* unsure this signal is not blocked */
@ -266,7 +266,7 @@ static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void
sa.sa_mask = global_sigmask; sa.sa_mask = global_sigmask;
if (sigaction(signo, &sa, NULL) < 0) { if (sigaction(signo, &sa, NULL) < 0) {
zend_error(E_ERROR, "Error installing signal handler for %d", signo); zend_error_noreturn(E_ERROR, "Error installing signal handler for %d", signo);
} }
return SUCCESS; return SUCCESS;

View File

@ -600,7 +600,7 @@ Balloc
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
if (!rv) { if (!rv) {
FREE_DTOA_LOCK(0); FREE_DTOA_LOCK(0);
zend_error(E_ERROR, "Balloc() failed to allocate memory"); zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory");
} }
#else #else
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
@ -613,7 +613,7 @@ Balloc
rv = (Bigint*)MALLOC(len*sizeof(double)); rv = (Bigint*)MALLOC(len*sizeof(double));
if (!rv) { if (!rv) {
FREE_DTOA_LOCK(0); FREE_DTOA_LOCK(0);
zend_error(E_ERROR, "Balloc() failed to allocate memory"); zend_error_noreturn(E_ERROR, "Balloc() failed to allocate memory");
} }
#endif #endif
rv->k = k; rv->k = k;

View File

@ -147,7 +147,7 @@ ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
case IS_CONSTANT_AST: case IS_CONSTANT_AST:
case IS_OBJECT: case IS_OBJECT:
case IS_RESOURCE: case IS_RESOURCE:
zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources"); zend_error_noreturn(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
break; break;
case IS_REFERENCE: { case IS_REFERENCE: {
zend_reference *ref = (zend_reference*)Z_REF_P(zvalue); zend_reference *ref = (zend_reference*)Z_REF_P(zvalue);
@ -178,7 +178,7 @@ ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC)
case IS_CONSTANT_AST: case IS_CONSTANT_AST:
case IS_OBJECT: case IS_OBJECT:
case IS_RESOURCE: case IS_RESOURCE:
zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources"); zend_error_noreturn(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
break; break;
case IS_REFERENCE: { case IS_REFERENCE: {
zend_reference *ref = (zend_reference*)Z_REF_P(zvalue); zend_reference *ref = (zend_reference*)Z_REF_P(zvalue);