]> granicus.if.org Git - php/commitdiff
Fix function copying in ZTS
authorNikita Popov <nikic@php.net>
Wed, 9 Apr 2014 19:40:01 +0000 (21:40 +0200)
committerNikita Popov <nikic@php.net>
Wed, 9 Apr 2014 21:41:16 +0000 (23:41 +0200)
Still doesn't entirely work :/

Zend/zend.c
Zend/zend_compile.c

index 1fd8b4840bfffcf1121c6479c0346c588aef671b..b2cc16a5b7719ebe729125823a366ceab017d1fa 100644 (file)
@@ -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);
index f5fda549b637ce496cbb65c748b54fff9918e07c..bd678c6d8bc176430439b46db7a0fdac8b304c06 100644 (file)
@@ -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