cvs: ZendEngine2 / zend_execute.c zend_vm_def.h zend_vm_execute.h /tests bug37251.phpt

From: Date: Fri, 05 May 2006 08:04:55 +0000
Subject: cvs: ZendEngine2 / zend_execute.c zend_vm_def.h zend_vm_execute.h /tests bug37251.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4836@lists.php.net to get a copy of this message
dmitry Fri May 5 08:04:55 2006 UTC Added files: /ZendEngine2/tests bug37251.phpt Modified files: /ZendEngine2 zend_execute.c zend_vm_def.h zend_vm_execute.h Log: Fixed bug #37251 (deadlock when custom error handler is to catch array type hint error). http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_execute.c?r1=1.739&r2=1.740&diff_format=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.739 ZendEngine2/zend_execute.c:1.740 --- ZendEngine2/zend_execute.c:1.739 Thu Mar 16 10:33:23 2006 +++ ZendEngine2/zend_execute.c Fri May 5 08:04:55 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.739 2006/03/16 10:33:23 dmitry Exp $ */ +/* $Id: zend_execute.c,v 1.740 2006/05/05 08:04:55 dmitry Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -470,7 +470,7 @@ } } -static inline void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg TSRMLS_DC) +static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zval *arg TSRMLS_DC) { zend_arg_info *cur_arg_info; zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data; @@ -479,7 +479,7 @@ if (!zf->common.arg_info || arg_num>zf->common.num_args) { - return; + return 1; } cur_arg_info = &zf->common.arg_info[arg_num-1]; @@ -494,6 +494,7 @@ } else { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name); } + return 0; } switch (Z_TYPE_P(arg)) { case IS_NULL: @@ -503,14 +504,14 @@ } else { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must not be null", arg_num, fclass, fsep, fname); } + return 0; } break; case IS_OBJECT: { zend_class_entry *ce = zend_u_fetch_class(UG(unicode) ? IS_UNICODE : IS_STRING, cur_arg_info->class_name, cur_arg_info->class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC); if (!instanceof_function(Z_OBJCE_P(arg), ce TSRMLS_CC)) { char *error_msg; - - if (ce->ce_flags & ZEND_ACC_INTERFACE) { + if (ce->ce_flags & ZEND_ACC_INTERFACE) { error_msg = "implement interface"; } else { error_msg = "be an instance of"; @@ -520,6 +521,7 @@ } else { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must %s %v", arg_num, fclass, fsep, fname, error_msg, ce->name); } + return 0; } } break; @@ -529,15 +531,16 @@ } else { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v", arg_num, fclass, fsep, fname, cur_arg_info->class_name); } - break; + return 0; } - } else if (cur_arg_info->array_type_hint) { + } else if (cur_arg_info->array_type_hint) { if (!arg) { if (ptr && ptr->op_array) { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array, called in %s on line %d and defined", arg_num, fclass, fsep, fname, ptr->op_array->filename, ptr->opline->lineno); } else { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array", arg_num, fclass, fsep, fname); } + return 0; } switch (Z_TYPE_P(arg)) { case IS_NULL: @@ -547,6 +550,7 @@ } else { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must not be null", arg_num, fclass, fsep, fname); } + return 0; } break; case IS_ARRAY: @@ -557,9 +561,10 @@ } else { zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an array", arg_num, fclass, fsep, fname); } - break; + return 0; } } + return 1; } http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_def.h?r1=1.110&r2=1.111&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.110 ZendEngine2/zend_vm_def.h:1.111 --- ZendEngine2/zend_vm_def.h:1.110 Wed Apr 12 11:38:08 2006 +++ ZendEngine2/zend_vm_def.h Fri May 5 08:04:55 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.110 2006/04/12 11:38:08 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.111 2006/05/05 08:04:55 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -2286,11 +2286,12 @@ zstr class_name = get_active_class_name(&space TSRMLS_CC); zend_execute_data *ptr = EX(prev_execute_data); - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC); - if(ptr && ptr->op_array) { - zend_error(E_WARNING, "Missing argument %ld for %v%s%v(), called in %s on line %d and defined", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C), ptr->op_array->filename, ptr->opline->lineno); - } else { - zend_error(E_WARNING, "Missing argument %ld for %v%s%v()", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C)); + if (zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC)) { + if(ptr && ptr->op_array) { + zend_error(E_WARNING, "Missing argument %ld for %v%s%v(), called in %s on line %d and defined", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C), ptr->op_array->filename, ptr->opline->lineno); + } else { + zend_error(E_WARNING, "Missing argument %ld for %v%s%v()", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C)); + } } if (opline->result.op_type == IS_VAR) { PZVAL_UNLOCK_FREE(*EX_T(opline->result.u.var).var.ptr_ptr); http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_vm_execute.h?r1=1.114&r2=1.115&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.114 ZendEngine2/zend_vm_execute.h:1.115 --- ZendEngine2/zend_vm_execute.h:1.114 Wed Apr 12 11:38:08 2006 +++ ZendEngine2/zend_vm_execute.h Fri May 5 08:04:55 2006 @@ -370,11 +370,12 @@ zstr class_name = get_active_class_name(&space TSRMLS_CC); zend_execute_data *ptr = EX(prev_execute_data); - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC); - if(ptr && ptr->op_array) { - zend_error(E_WARNING, "Missing argument %ld for %v%s%v(), called in %s on line %d and defined", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C), ptr->op_array->filename, ptr->opline->lineno); - } else { - zend_error(E_WARNING, "Missing argument %ld for %v%s%v()", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C)); + if (zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC)) { + if(ptr && ptr->op_array) { + zend_error(E_WARNING, "Missing argument %ld for %v%s%v(), called in %s on line %d and defined", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C), ptr->op_array->filename, ptr->opline->lineno); + } else { + zend_error(E_WARNING, "Missing argument %ld for %v%s%v()", Z_LVAL(opline->op1.u.constant), class_name, space, get_active_function_name(TSRMLS_C)); + } } if (opline->result.op_type == IS_VAR) { PZVAL_UNLOCK_FREE(*EX_T(opline->result.u.var).var.ptr_ptr); http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/bug37251.phpt?view=markup&rev=1.1 Index: ZendEngine2/tests/bug37251.phpt +++ ZendEngine2/tests/bug37251.phpt --TEST-- Bug #37251 (deadlock when custom error handler is to catch array type hint error) --FILE-- <?php function error_handler($errno, $errstr, $errfile, $errline, $context) { echo 'OK'; } set_error_handler('error_handler'); class Foo { function bar(array $foo) { } } $foo = new Foo(); $foo->bar(); --EXPECT-- OK

« previous php.zend-engine.cvs (#4836) next »