gh-131591: Reset RemoteDebuggerSuupport state after fork (#132793)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
Nadeshiko Manju 2025-04-25 08:40:01 +08:00 committed by GitHub
parent e54e828852
commit 3a39e33ee4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View file

@ -677,6 +677,14 @@ PyOS_AfterFork_Parent(void)
run_at_forkers(interp->after_forkers_parent, 0);
}
static void
reset_remotedebug_data(PyThreadState *tstate)
{
tstate->remote_debugger_support.debugger_pending_call = 0;
memset(tstate->remote_debugger_support.debugger_script_path, 0, MAX_SCRIPT_PATH_SIZE);
}
void
PyOS_AfterFork_Child(void)
{
@ -710,6 +718,8 @@ PyOS_AfterFork_Child(void)
goto fatal_error;
}
reset_remotedebug_data(tstate);
// Remove the dead thread states. We "start the world" once we are the only
// thread state left to undo the stop the world call in `PyOS_BeforeFork`.
// That needs to happen before `_PyThreadState_DeleteList`, because that