com php-src: Fix function copying in ZTS: Zend/zend.c Zend/zend_compile.c
| From: | Dmitry Stogov | Date: | Wed, 09 Apr 2014 21:41:16 +0000 |
| Subject: | com php-src: Fix function copying in ZTS: Zend/zend.c Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77457@lists.php.net to get a copy of this message | ||
Commit: 3ce96eabc0f8d2f1ab697cd1cdfc3d4883b50e11
Author: Nikita Popov <nikic@php.net> Wed, 9 Apr 2014 21:40:01 +0200
Parents: 20f2e5986e7d9e5978eaed8d6d60cd6bf917ea37
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3ce96eabc0f8d2f1ab697cd1cdfc3d4883b50e11
Log:
Fix function copying in ZTS
Still doesn't entirely work :/
Changed paths:
M Zend/zend.c
M Zend/zend_compile.c
Diff:
diff --git a/Zend/zend.c b/Zend/zend.c
index 1fd8b48..b2cc16a 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -515,13 +515,21 @@ static void zend_init_exception_op(TSRMLS_D) /* {{{ */
/* }}} */
#ifdef ZTS
+static void function_copy_ctor(zval *zv)
+{
+ zend_function *old_func = Z_FUNC_P(zv);
+ Z_FUNC_P(zv) = pemalloc(sizeof(zend_internal_function), 1);
+ memcpy(Z_FUNC_P(zv), old_func, sizeof(zend_internal_function));
+ function_add_ref(Z_FUNC_P(zv));
+}
+
static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS_DC) /* {{{ */
{
compiler_globals->compiled_filename = NULL;
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
- zend_hash_copy(compiler_globals->function_table, global_function_table, NULL);
+ zend_hash_copy(compiler_globals->function_table, global_function_table, function_copy_ctor);
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index f5fda54..bd678c6 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3093,6 +3093,10 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */
zend_hash_copy(op_array->static_variables, static_variables, zval_add_ref_unref);
}
op_array->run_time_cache = NULL;
+ } else if (function->type == ZEND_INTERNAL_FUNCTION) {
+ if (function->common.function_name) {
+ STR_ADDREF(function->common.function_name);
+ }
}
}
/* }}} */
@@ -6951,10 +6955,10 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool
nullify
if (CG(static_members_table) && n >= CG(last_static_member)) {
/* Support for run-time declaration: dl() */
CG(last_static_member) = n+1;
- CG(static_members_table) = realloc(CG(static_members_table), (n+1)*sizeof(zval**));
+ CG(static_members_table) = realloc(CG(static_members_table), (n+1)*sizeof(zval*));
CG(static_members_table)[n] = NULL;
}
- ce->static_members_table = (zval**)(zend_intptr_t)n;
+ ce->static_members_table = (zval*)(zend_intptr_t)n;
#else
ce->static_members_table = NULL;
#endif