Skip to content

Commit

Permalink
pythongh-121390: tracemalloc: Fix tracebacks memory leak (pythonGH-12…
Browse files Browse the repository at this point in the history
…1391)

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 <[email protected]>
  • Loading branch information
jbrobst authored and miss-islington committed Jul 5, 2024
1 parent de86aaa commit b59f27a
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 b59f27a

Please sign in to comment.