From 280914cd46f4411a2e01150bf9d9c53dff19fa66 Mon Sep 17 00:00:00 2001 From: shadchin Date: Wed, 24 Jun 2026 07:09:14 +0300 Subject: Update Python 3 to 3.13.14 commit_hash:9913a0288f56b5ddd0f99e5b2ff1569d491cbe5d --- contrib/tools/python3/Python/perf_trampoline.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'contrib/tools/python3/Python/perf_trampoline.c') diff --git a/contrib/tools/python3/Python/perf_trampoline.c b/contrib/tools/python3/Python/perf_trampoline.c index 7ef9eca11f5..e296605c16a 100644 --- a/contrib/tools/python3/Python/perf_trampoline.c +++ b/contrib/tools/python3/Python/perf_trampoline.c @@ -211,9 +211,8 @@ enum perf_trampoline_type { static void free_code_arenas(void); static void -perf_trampoline_reset_state(void) +perf_trampoline_clear_code_watcher(void) { - free_code_arenas(); if (code_watcher_id >= 0) { PyCode_ClearWatcher(code_watcher_id); code_watcher_id = -1; @@ -221,6 +220,13 @@ perf_trampoline_reset_state(void) extra_code_index = -1; } +static void +perf_trampoline_reset_state(void) +{ + free_code_arenas(); + perf_trampoline_clear_code_watcher(); +} + static int perf_trampoline_code_watcher(PyCodeEvent event, PyCodeObject *co) { @@ -623,9 +629,10 @@ _PyPerfTrampoline_AfterFork_Child(void) // After fork, Fini may leave the old code watcher registered // if trampolined code objects from the parent still exist // (trampoline_refcount > 0). Clear it unconditionally before - // Init registers a new one, to prevent two watchers sharing - // the same globals and double-decrementing trampoline_refcount. - perf_trampoline_reset_state(); + // Init registers a new one, but keep the old arenas mapped: the + // child may still need to return through trampoline frames that + // were on the C stack at fork(). + perf_trampoline_clear_code_watcher(); _PyPerfTrampoline_Init(1); } } -- cgit v1.3