Add debug offsets for free threaded builds (#123041)

This commit is contained in:
Pablo Galindo Salgado 2024-08-15 19:42:41 +01:00 committed by GitHub
parent b15b81ed4f
commit d7a3df9150
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 5 deletions

View file

@ -390,7 +390,7 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS
Note that we initialize "initial" relative to _PyRuntime,
to ensure pre-initialized pointers point to the active
runtime state (and not "initial"). */
static const _PyRuntimeState initial = _PyRuntimeState_INIT(_PyRuntime);
static const _PyRuntimeState initial = _PyRuntimeState_INIT(_PyRuntime, "");
_Py_COMP_DIAG_POP
#define LOCKS_INIT(runtime) \
@ -455,6 +455,8 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
// Py_Initialize() must be running again.
// Reset to _PyRuntimeState_INIT.
memcpy(runtime, &initial, sizeof(*runtime));
// Preserve the cookie from the original runtime.
memcpy(runtime->debug_offsets.cookie, _Py_Debug_Cookie, 8);
assert(!runtime->_initialized);
}