]> granicus.if.org Git - php/commitdiff
Fixed bug #61442 (exception threw in __autoload can not be catched)
authorXinchen Hui <laruence@php.net>
Wed, 19 Sep 2012 11:40:59 +0000 (19:40 +0800)
committerXinchen Hui <laruence@php.net>
Wed, 19 Sep 2012 11:40:59 +0000 (19:40 +0800)
NEWS
Zend/tests/bug61442.phpt [new file with mode: 0644]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/NEWS b/NEWS
index 181e66d3880ae10edb92434fa89613ae626df4f4..787d76d7207cf2626300ffeddfea961e9ed04c3c 100644 (file)
--- 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 (file)
index 0000000..3af534f
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Bug #61442 (exception threw in __autoload can not be catched)
+--FILE--
+<?php
+function __autoload($name) {
+    throw new Exception("Unable to load $name");
+}
+
+try {
+    $obj = new NonLoadableClass();
+} catch (Exception $e) {
+    var_dump($e->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"
index 34020fb9fc0b14eee47924bf72373e9d9d64421f..22d77dd79f900ed8ba46ac07d3771c00fde2598d 100644 (file)
@@ -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));
                        }
index 2889965e9d44b125e42a2a953e89fbfdb6e229c9..148160204052fd9e60033f6e51b33a470273c646 100644 (file)
@@ -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));
                        }