mirror of
https://github.com/python/cpython.git
synced 2026-04-14 15:50:50 +00:00
[3.13] gh-144766: Fix a crash in fork child process when perf support is enabled. (GH-144795) (#144818)
(cherry picked from commit 5922149a50)
Co-authored-by: Yilei <hi@mangoumbrella.com>
This commit is contained in:
parent
48dd852025
commit
0151abcd9f
3 changed files with 49 additions and 0 deletions
|
|
@ -620,6 +620,12 @@ _PyPerfTrampoline_AfterFork_Child(void)
|
|||
int was_active = _PyIsPerfTrampolineActive();
|
||||
_PyPerfTrampoline_Fini();
|
||||
if (was_active) {
|
||||
// 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();
|
||||
_PyPerfTrampoline_Init(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue