From fd0b3ea663431b7adaedde11668fbc0b6ba07494 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 19 Sep 2012 19:40:59 +0800 Subject: [PATCH] Fixed bug #61442 (exception threw in __autoload can not be catched) --- NEWS | 2 ++ Zend/tests/bug61442.phpt | 30 ++++++++++++++++++++++++++++++ Zend/zend_vm_def.h | 6 ++++++ Zend/zend_vm_execute.h | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 Zend/tests/bug61442.phpt diff --git a/NEWS b/NEWS index 181e66d388..787d76d720 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ PHP NEWS some builtin classes). (Laruence) . Fixed bug #61767 (Shutdown functions not called in certain error situation). (Dmitry) + . Fixed bug #61442 (exception threw in __autoload can not be catched). + (Laruence) . Fixed bug #60909 (custom error handler throwing Exception + fatal error = no shutdown function). (Dmitry) diff --git a/Zend/tests/bug61442.phpt b/Zend/tests/bug61442.phpt new file mode 100644 index 0000000000..3af534fec9 --- /dev/null +++ b/Zend/tests/bug61442.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #61442 (exception threw in __autoload can not be catched) +--FILE-- +getMessage()); +} + +try { + $obj = NonLoadableClass::a(); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +try { + $obj = NonLoadableClass::UNDEFINED_CONST; +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +--EXPECTF-- +string(31) "Unable to load NonLoadableClass" +string(31) "Unable to load NonLoadableClass" +string(31) "Unable to load NonLoadableClass" diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 34020fb9fc..22d77dd79f 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1990,6 +1990,9 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS if (OP1_TYPE == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -3043,6 +3046,9 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) if (OP1_TYPE == IS_CONST) { ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant)); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 2889965e9d..1481602040 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2688,6 +2688,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -2836,6 +2839,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO if (IS_CONST == IS_CONST) { ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant)); } @@ -3259,6 +3265,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -3725,6 +3734,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -3947,6 +3959,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -4381,6 +4396,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN if (IS_CONST == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -10498,6 +10516,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -10646,6 +10667,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE if (IS_VAR == IS_CONST) { ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant)); } @@ -12305,6 +12329,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -14107,6 +14134,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -15003,6 +15033,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -16496,6 +16529,9 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ if (IS_VAR == IS_CONST) { /* no function found. try a static method in class */ ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL(opline->op1.u.constant)); } @@ -17860,6 +17896,9 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC if (IS_UNUSED == IS_CONST) { ce = zend_fetch_class(Z_STRVAL(opline->op1.u.constant), Z_STRLEN(opline->op1.u.constant), opline->extended_value TSRMLS_CC); + if (UNEXPECTED(EG(exception) != NULL)) { + ZEND_VM_CONTINUE(); + } if (!ce) { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL(opline->op2.u.constant)); } -- 2.40.0