Skip to content

[3.15] gh-159739: Guard cProfile against reentry while processing an external timer (GH-160405) - #160566

Merged
JelleZijlstra merged 1 commit into
python:3.15from
miss-islington:backport-c2b7e0a-3.15
Oct 24, 2026
Merged

JelleZijlstra merged 1 commit into
python:3.15from
miss-islington:backport-c2b7e0a-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

An external timer can run Python again when the profiler converts or releases its result or reports an unraisable exception. Calling clear() or disable() at that point could free a profiling context still in use. Calling Profiler.init() from the timer could also destroy the active callable. Keep the guard active through result handling and reject reinitialization while an external timer is running.
(cherry picked from commit c2b7e0a)

Co-authored-by: Jelle Zijlstra jelle@openai.com

…xternal timer (pythonGH-160405)

An external timer can run Python again when the profiler converts or releases its result or reports an unraisable exception. Calling clear() or disable() at that point could free a profiling context still in use. Calling Profiler.__init__() from the timer could also destroy the active callable. Keep the guard active through result handling and reject reinitialization while an external timer is running.
(cherry picked from commit c2b7e0a)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
@JelleZijlstra
JelleZijlstra merged commit 5c4a4db into python:3.15 Oct 24, 2026
56 checks passed
@miss-islington
miss-islington deleted the backport-c2b7e0a-3.15 branch October 24, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants