From: Nikita Popov Date: Wed, 9 Apr 2014 19:40:01 +0000 (+0200) Subject: Fix function copying in ZTS X-Git-Tag: POST_PHPNG_MERGE~412^2~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ce96eabc0f8d2f1ab697cd1cdfc3d4883b50e11;p=php Fix function copying in ZTS Still doesn't entirely work :/ --- diff --git a/Zend/zend.c b/Zend/zend.c index 1fd8b4840b..b2cc16a5b7 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 f5fda549b6..bd678c6d8b 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