cvs: ZendEngine2 / zend.c zend_exceptions.c

[email protected] ("Dmitry Stogov")
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1208427687@cvsserver>
dmitry		Thu Apr 17 10:21:27 2008 UTC

  Modified files:              
    /ZendEngine2	zend.c zend_exceptions.c 
  Log:
  Fixed bug #44226 (Throwing an exception causes crash in multithreaded SAPI)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.413&r2=1.414&diff_format=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.413 ZendEngine2/zend.c:1.414
--- ZendEngine2/zend.c:1.413	Fri Apr 11 09:43:49 2008
+++ ZendEngine2/zend.c	Thu Apr 17 10:21:25 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.c,v 1.413 2008/04/11 09:43:49 dmitry Exp $ */
+/* $Id: zend.c,v 1.414 2008/04/17 10:21:25 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_extensions.h"
@@ -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 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 @@
 	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 @@
 
 #ifndef ZTS
 	zend_init_rsrc_plist(TSRMLS_C);
+	zend_init_exception_op(TSRMLS_C);
 #endif
 
 	if (start_builtin_functions) {
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_exceptions.c?r1=1.119&r2=1.120&diff_format=u
Index: ZendEngine2/zend_exceptions.c
diff -u ZendEngine2/zend_exceptions.c:1.119 ZendEngine2/zend_exceptions.c:1.120
--- ZendEngine2/zend_exceptions.c:1.119	Thu Feb 28 13:30:43 2008
+++ ZendEngine2/zend_exceptions.c	Thu Apr 17 10:21:25 2008
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_exceptions.c,v 1.119 2008/02/28 13:30:43 felipe Exp $ */
+/* $Id: zend_exceptions.c,v 1.120 2008/04/17 10:21:25 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -654,23 +654,6 @@
 {
 	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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.