Skip to content

gh-131591: Reset RemoteDebuggerSuupport state after fork #132793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reset any :pep:`768` remote debugging pending call in children after :func:`os.fork` calls.
10 changes: 10 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
Loading