PY-60597 Set global debugger to None and clear thread local info when stopping tracing

The global debugger reference should be set to `None` right away. Otherwise, the reference to the stopped debugger can leak to `ThreadTracer` leading to skipped breakpoints. The same applies for the thread local info. If it is not reset, the frame evaluation code will continue using a tracing function with the stale debugger reference.

GitOrigin-RevId: 62b38316e4da760213810a55aa98db289ce45720
This commit is contained in:
Andrey Lisin
2024-06-19 16:01:32 +02:00
committed by intellij-monorepo-bot
parent eab1b5db01
commit a42f335cf4

View File

@@ -59,7 +59,8 @@ from _pydevd_bundle.pydevd_kill_all_pydevd_threads import kill_all_pydev_threads
from _pydevd_bundle.pydevd_trace_dispatch import (
trace_dispatch as _trace_dispatch, global_cache_skips, global_cache_frame_skips, show_tracing_warning)
from _pydevd_frame_eval.pydevd_frame_eval_main import (
frame_eval_func, dummy_trace_dispatch, show_frame_eval_warning)
frame_eval_func, clear_thread_local_info, dummy_trace_dispatch,
show_frame_eval_warning)
from _pydevd_bundle.pydevd_pep_669_tracing_wrapper import enable_pep669_monitoring
from _pydevd_bundle.pydevd_additional_thread_info import set_additional_thread_info
from _pydevd_bundle.pydevd_utils import save_main_module, is_current_thread_main_thread, \
@@ -385,8 +386,13 @@ def stoptrace():
kill_all_pydev_threads()
set_global_debugger(None)
connected = False
if clear_thread_local_info is not None:
clear_thread_local_info()
#=======================================================================================================================
# PyDB
@@ -1953,7 +1959,6 @@ def settrace_forked():
from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder
GlobalDebuggerHolder.global_dbg = None
from _pydevd_frame_eval.pydevd_frame_eval_main import clear_thread_local_info
host, port = dispatch()
import pydevd_tracing