From 4dc52cfb4b8e1064a4f586724cc764e30c2c6978 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Thu, 5 Mar 2020 22:58:12 +0400 Subject: [PATCH] [Core] Track who calls memory pool destroy. --- src/switch_core_memory.c | 11 +++++++++++ src/switch_scheduler.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c index eb35f1b2ca..2cf007fad2 100644 --- a/src/switch_core_memory.c +++ b/src/switch_core_memory.c @@ -463,7 +463,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_new_memory_pool(switch_memor SWITCH_DECLARE(switch_status_t) switch_core_perform_destroy_memory_pool(switch_memory_pool_t **pool, const char *file, const char *func, int line) { + char *tmp; + const char *tag; switch_assert(pool != NULL); + + /* In tag we store who calls the pool creation. + Now we append it with who calls the pool destroy. + */ + if (*pool) { + tag = apr_pool_tag(*pool, NULL); + tmp = switch_core_sprintf(*pool, "%s,%s:%d", (tag ? tag : ""), file, line); + apr_pool_tag(*pool, tmp); + } #ifdef DEBUG_ALLOC2 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Free Pool %s\n", (void *) *pool, apr_pool_tag(*pool, NULL)); diff --git a/src/switch_scheduler.c b/src/switch_scheduler.c index 6452fa9cc2..c08d1071b4 100644 --- a/src/switch_scheduler.c +++ b/src/switch_scheduler.c @@ -54,7 +54,7 @@ static struct { int task_thread_running; switch_queue_t *event_queue; switch_memory_pool_t *memory_pool; -} globals; +} globals = { 0 }; static void switch_scheduler_execute(switch_scheduler_task_container_t *tp) {