From a94be364968da56a3973e0337e42bdcc6c2346ed Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Thu, 3 Sep 2015 09:56:01 +0100 Subject: [PATCH 1/3] some missing TSRM stuff for 7 plug a couple of leaks in xdebug_stack.c (xdebug_get_function_stack) --- xdebug.c | 12 +++++++++++- xdebug_stack.c | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/xdebug.c b/xdebug.c index 33790eb0f..ca60178a7 100644 --- a/xdebug.c +++ b/xdebug.c @@ -172,11 +172,15 @@ zend_module_entry xdebug_module_entry = { STANDARD_MODULE_PROPERTIES_EX }; - ZEND_DECLARE_MODULE_GLOBALS(xdebug) #if COMPILE_DL_XDEBUG ZEND_GET_MODULE(xdebug) +#if PHP_VERSION_ID >= 70000 +# ifdef ZTS + ZEND_TSRMLS_CACHE_DEFINE(); +# endif +#endif #endif static PHP_INI_MH(OnUpdateServer) @@ -1020,6 +1024,12 @@ PHP_RINIT_FUNCTION(xdebug) zval **dummy; #endif +#if PHP_VERSION_ID >= 70000 +#if defined(ZTS) && defined(COMPILE_DL_XDEBUG) + ZEND_TSRMLS_CACHE_UPDATE(); +#endif +#endif + /* Get the ide key for this session */ XG(ide_key) = NULL; idekey = xdebug_env_key(TSRMLS_C); diff --git a/xdebug_stack.c b/xdebug_stack.c index 9cf973950..f9b142a9f 100644 --- a/xdebug_stack.c +++ b/xdebug_stack.c @@ -1632,6 +1632,9 @@ PHP_FUNCTION(xdebug_get_function_stack) } else { add_index_zval(params, j, vparams); } +#if PHP_VERSION_ID >= 70000 + efree(params); +#endif params = vparams; variadic_opened = 1; } @@ -1653,6 +1656,10 @@ PHP_FUNCTION(xdebug_get_function_stack) } add_next_index_zval(return_value, frame); +#if PHP_VERSION_ID >= 70000 + efree(params); + efree(frame); +#endif } } /* }}} */ From 673c1921525f4d7ede66df5a1ba78e3787ae7c7f Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Thu, 3 Sep 2015 10:18:38 +0100 Subject: [PATCH 2/3] plug moar leaks --- xdebug_code_coverage.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/xdebug_code_coverage.c b/xdebug_code_coverage.c index 4604b8ff0..e441e6b04 100644 --- a/xdebug_code_coverage.c +++ b/xdebug_code_coverage.c @@ -1067,10 +1067,19 @@ static void add_branches(zval *retval, xdebug_branch_info *branch_info TSRMLS_DC add_assoc_zval(branch, "out_hit", out_hit); add_index_zval(branches, i, branch); +#if PHP_VERSION_ID >= 70000 + efree(out_hit); + efree(out); + efree(branch); +#endif } } add_assoc_zval_ex(retval, "branches", 9, branches); + +#if PHP_VERSION_ID >= 70000 + efree(branches); +#endif } static void add_paths(zval *retval, xdebug_branch_info *branch_info TSRMLS_DC) @@ -1096,9 +1105,18 @@ static void add_paths(zval *retval, xdebug_branch_info *branch_info TSRMLS_DC) add_assoc_long(path_container, "hit", branch_info->path_info.paths[i]->hit); add_next_index_zval(paths, path_container); + +#if PHP_VERSION_ID >= 70000 + efree(path_container); + efree(path); +#endif } add_assoc_zval_ex(retval, "paths", 6, paths); + +#if PHP_VERSION_ID >= 70000 + efree(paths); +#endif } static void add_cc_function(void *ret, xdebug_hash_element *e) @@ -1117,6 +1135,10 @@ static void add_cc_function(void *ret, xdebug_hash_element *e) } add_assoc_zval_ex(retval, function->name, strlen(function->name) + 1, function_info); + +#if PHP_VERSION_ID >= 70000 + efree(function_info); +#endif } static void add_file(void *ret, xdebug_hash_element *e) @@ -1155,9 +1177,17 @@ static void add_file(void *ret, xdebug_hash_element *e) add_assoc_zval_ex(file_info, "functions", 10, functions); add_assoc_zval_ex(retval, file->name, strlen(file->name) + 1, file_info); +#if PHP_VERSION_ID >= 70000 + efree(functions); + efree(file_info); +#endif } else { add_assoc_zval_ex(retval, file->name, strlen(file->name) + 1, lines); } + +#if PHP_VERSION_ID >= 70000 + efree(lines); +#endif } PHP_FUNCTION(xdebug_get_code_coverage) From 40ae9613c64b5e8e9f30e5541a75d90e1179eea5 Mon Sep 17 00:00:00 2001 From: Joe Watkins Date: Thu, 3 Sep 2015 16:14:49 +0100 Subject: [PATCH 3/3] fix wrong filename for closures in trace --- xdebug_stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xdebug_stack.c b/xdebug_stack.c index f9b142a9f..a3c5eeec5 100644 --- a/xdebug_stack.c +++ b/xdebug_stack.c @@ -1070,7 +1070,7 @@ static void xdebug_build_fname(xdebug_func *tmp, zend_execute_data *edata TSRMLS if (strcmp(edata->func->common.function_name->val, "{closure}") == 0) { tmp->function = xdebug_sprintf( "{closure:%s:%d-%d}", - edata->func->op_array.filename, + edata->func->op_array.filename->val, edata->func->op_array.line_start, edata->func->op_array.line_end );