From b59f27ac5362ef6bd3c00edffaab19eeb1445228 Mon Sep 17 00:00:00 2001 From: Josh Brobst Date: Fri, 5 Jul 2024 02:39:48 -0400 Subject: [PATCH] gh-121390: tracemalloc: Fix tracebacks memory leak (GH-121391) The tracemalloc_tracebacks hash table has traceback keys and NULL values, but its destructors do not reflect this -- key_destroy_func is NULL while value_destroy_func is raw_free. Swap these to free the traceback keys instead. (cherry picked from commit db39bc42f90c151b298f97b780e62703adbf1221) Co-authored-by: Josh Brobst --- Python/tracemalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/tracemalloc.c b/Python/tracemalloc.c index bc765623522288..e13064bd145e8e 100644 --- a/Python/tracemalloc.c +++ b/Python/tracemalloc.c @@ -836,7 +836,7 @@ _PyTraceMalloc_Init(void) tracemalloc_tracebacks = hashtable_new(hashtable_hash_traceback, hashtable_compare_traceback, - NULL, raw_free); + raw_free, NULL); tracemalloc_traces = tracemalloc_create_traces_table(); tracemalloc_domains = tracemalloc_create_domains_table();