]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-121390: tracemalloc: Fix tracebacks memory leak (GH-121391) (#121392)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 21 Jul 2024 13:12:13 +0000 (15:12 +0200)
committerGitHub <noreply@github.com>
Sun, 21 Jul 2024 13:12:13 +0000 (13:12 +0000)
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 <jbrobst@proton.me>
Python/tracemalloc.c

index fee7dd0e56d96d6ca227306fdadda53382f32de5..e58b60ddd5e484a9a29fc98e13b909b1ac077533 100644 (file)
@@ -838,7 +838,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();