From: Dmitry Stogov Date: Thu, 17 Apr 2008 10:21:25 +0000 (+0000) Subject: Fixed bug #44226 (Throwing an exception causes crash in multithreaded SAPI) X-Git-Tag: RELEASE_2_0_0b1~339 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0699d994c664623657145cc42409cf4f420923db;p=php Fixed bug #44226 (Throwing an exception causes crash in multithreaded SAPI) --- diff --git a/Zend/zend.c b/Zend/zend.c index 170bf560ee..64bf6c1ca3 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -28,6 +28,7 @@ #include "zend_exceptions.h" #include "zend_builtin_functions.h" #include "zend_ini.h" +#include "zend_vm.h" #include "zend_unicode.h" #ifdef ZTS @@ -829,6 +830,27 @@ static void class_to_unicode(zend_class_entry **ce TSRMLS_DC) /* {{{ */ } /* }}} */ +static void zend_init_exception_op(TSRMLS_D) /* {{{ */ +{ + memset(EG(exception_op), 0, sizeof(EG(exception_op))); + EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION; + EG(exception_op)[0].op1.op_type = IS_UNUSED; + EG(exception_op)[0].op2.op_type = IS_UNUSED; + EG(exception_op)[0].result.op_type = IS_UNUSED; + ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)); + EG(exception_op)[1].opcode = ZEND_HANDLE_EXCEPTION; + EG(exception_op)[1].op1.op_type = IS_UNUSED; + EG(exception_op)[1].op2.op_type = IS_UNUSED; + EG(exception_op)[1].result.op_type = IS_UNUSED; + ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+1); + EG(exception_op)[2].opcode = ZEND_HANDLE_EXCEPTION; + EG(exception_op)[2].op1.op_type = IS_UNUSED; + EG(exception_op)[2].op2.op_type = IS_UNUSED; + EG(exception_op)[2].result.op_type = IS_UNUSED; + ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+2); +} +/* }}} */ + #ifdef ZTS static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS_DC) /* {{{ */ { @@ -889,6 +911,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS zend_startup_constants(TSRMLS_C); zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE); zend_init_rsrc_plist(TSRMLS_C); + zend_init_exception_op(TSRMLS_C); EG(lambda_count) = 0; EG(user_error_handler) = NULL; EG(user_exception_handler) = NULL; @@ -1131,6 +1154,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i #ifndef ZTS zend_init_rsrc_plist(TSRMLS_C); + zend_init_exception_op(TSRMLS_C); #endif if (start_builtin_functions) { diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index ffcf9c6cd1..fa633cea69 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -654,23 +654,6 @@ void zend_register_default_exception(TSRMLS_D) /* {{{ */ { zend_class_entry ce; - memset(EG(exception_op), 0, sizeof(EG(exception_op))); - EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION; - EG(exception_op)[0].op1.op_type = IS_UNUSED; - EG(exception_op)[0].op2.op_type = IS_UNUSED; - EG(exception_op)[0].result.op_type = IS_UNUSED; - ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)); - EG(exception_op)[1].opcode = ZEND_HANDLE_EXCEPTION; - EG(exception_op)[1].op1.op_type = IS_UNUSED; - EG(exception_op)[1].op2.op_type = IS_UNUSED; - EG(exception_op)[1].result.op_type = IS_UNUSED; - ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+1); - EG(exception_op)[2].opcode = ZEND_HANDLE_EXCEPTION; - EG(exception_op)[2].op1.op_type = IS_UNUSED; - EG(exception_op)[2].op2.op_type = IS_UNUSED; - EG(exception_op)[2].result.op_type = IS_UNUSED; - ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+2); - INIT_CLASS_ENTRY(ce, "Exception", default_exception_functions); default_exception_ce = zend_register_internal_class(&ce TSRMLS_CC); default_exception_ce->create_object = zend_default_exception_new;