Skip to content

gh-145846: Fix memory leak in _lsprof clearEntries() context chain#145847

Open
raminfp wants to merge 2 commits intopython:mainfrom
raminfp:fix-lsprof-clearentries-memleak
Open

gh-145846: Fix memory leak in _lsprof clearEntries() context chain#145847
raminfp wants to merge 2 commits intopython:mainfrom
raminfp:fix-lsprof-clearentries-memleak

Conversation

@raminfp
Copy link
Contributor

@raminfp raminfp commented Mar 12, 2026

Fix clearEntries() to walk the entire currentProfilerContext linked list instead of only freeing the top context, preventing memory leaks when clear() is called during nested profiled calls.

clearEntries() only freed the top currentProfilerContext but did not
walk the previous linked list. When clear() is called during active
profiling with nested calls, all contexts except the top one were
leaked. Fix by iterating the entire linked list, matching the existing
freelistProfilerContext cleanup pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant