PY-72009 Set global debugger after all its fields initialization

The `set_global_debugger` invocation has been moved to a later point to ensure all debugger fields are initialized first. This addresses potential issues in multithreaded environments where the debugger is accessible, but access to its fields may fail.

GitOrigin-RevId: 55dd63585f8dae94c6527d51dca3c2562b30c4ce
This commit is contained in:
Andrey Lisin
2024-05-29 12:25:40 +02:00
committed by intellij-monorepo-bot
parent 5773e12754
commit dbc08a7507

View File

@@ -408,7 +408,6 @@ class PyDB(object):
def __init__(self, set_as_global=True):
if set_as_global:
set_global_debugger(self)
pydevd_tracing.replace_sys_set_trace_func()
self.reader = None
@@ -517,6 +516,12 @@ class PyDB(object):
self.value_resolve_thread_list = []
if set_as_global:
# All debugger fields need to be initialized first. If they aren't,
# there can be instances in a multithreaded environment where the debugger
# is accessible but the attempts to access its fields may fail.
set_global_debugger(self)
def get_thread_local_trace_func(self):
try:
thread_trace_func = self._local_thread_trace_func.thread_trace_func