Skip to content

Commit 5ba67af

Browse files
gh-127117: Ensure the Correct Last Fields of PyInterpreterState and of _PyRuntimeState (gh-127118)
We add some comments so contributors can be aware and we move one out-of-place field up.
1 parent a5440d4 commit 5ba67af

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Include/internal/pycore_interp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ struct _is {
283283

284284
/* the initial PyInterpreterState.threads.head */
285285
_PyThreadStateImpl _initial_thread;
286+
// _initial_thread should be the last field of PyInterpreterState.
287+
// See https://github.com/python/cpython/issues/127117.
286288
};
287289

288290

Include/internal/pycore_runtime.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ typedef struct pyruntimestate {
169169
struct _Py_unicode_runtime_state unicode_state;
170170
struct _types_runtime_state types;
171171

172+
#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
173+
// Used in "Python/emscripten_trampoline.c" to choose between type
174+
// reflection trampoline and EM_JS trampoline.
175+
bool wasm_type_reflection_available;
176+
#endif
177+
172178
/* All the objects that are shared by the runtime's interpreters. */
173179
struct _Py_cached_objects cached_objects;
174180
struct _Py_static_objects static_objects;
@@ -189,13 +195,8 @@ typedef struct pyruntimestate {
189195

190196
/* _PyRuntimeState.interpreters.main */
191197
PyInterpreterState _main_interpreter;
192-
193-
#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
194-
// Used in "Python/emscripten_trampoline.c" to choose between type
195-
// reflection trampoline and EM_JS trampoline.
196-
bool wasm_type_reflection_available;
197-
#endif
198-
198+
// _main_interpreter should be the last field of _PyRuntimeState.
199+
// See https://github.com/python/cpython/issues/127117.
199200
} _PyRuntimeState;
200201

201202

0 commit comments

Comments
 (0)