From 3db7bf2d180be5475266411b62114c28a0d4f92c Mon Sep 17 00:00:00 2001 From: yihong Date: Mon, 8 Dec 2025 12:45:04 +0800 Subject: [PATCH] gh-142207: remove assertions incompatible under `profiling.sampling` (#142331) --- .../Library/2025-12-06-13-19-43.gh-issue-142207.x_X9oH.rst | 2 ++ Modules/_remote_debugging/threads.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-12-06-13-19-43.gh-issue-142207.x_X9oH.rst diff --git a/Misc/NEWS.d/next/Library/2025-12-06-13-19-43.gh-issue-142207.x_X9oH.rst b/Misc/NEWS.d/next/Library/2025-12-06-13-19-43.gh-issue-142207.x_X9oH.rst new file mode 100644 index 000000000000..69ca8c41ac9b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-12-06-13-19-43.gh-issue-142207.x_X9oH.rst @@ -0,0 +1,2 @@ +Fix: profiling.sampling may cause assertion ``!(has_gil && +gil_requested)`` diff --git a/Modules/_remote_debugging/threads.c b/Modules/_remote_debugging/threads.c index 69819eb8dcd6..774338f9dc24 100644 --- a/Modules/_remote_debugging/threads.c +++ b/Modules/_remote_debugging/threads.c @@ -339,12 +339,10 @@ unwind_stack_for_thread( #endif if (has_gil) { status_flags |= THREAD_STATUS_HAS_GIL; + // gh-142207 for remote debugging. + gil_requested = 0; } - // Assert that we never have both HAS_GIL and GIL_REQUESTED set at the same time - // This would indicate a race condition in the GIL state tracking - assert(!(has_gil && gil_requested)); - // Check CPU status long pthread_id = GET_MEMBER(long, ts, unwinder->debug_offsets.thread_state.thread_id); -- 2.47.3