Skip to content

Commit

Permalink
[3.12] gh-121390: tracemalloc: Fix tracebacks memory leak (GH-121391) (
Browse files Browse the repository at this point in the history
…#121393)

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 db39bc4)

Co-authored-by: Josh Brobst <jbrobst@proton.me>
  • Loading branch information
miss-islington and jbrobst committed Jul 5, 2024
1 parent de86aaa commit 9e542f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Python/tracemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9e542f9

Please sign in to comment.