Skip to content

Commit cea3112

Browse files
committed
gh-158539: Keep layout assertions with debug-offset validation
1 parent 6c0b716 commit cea3112

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎Modules/_remote_debugging/debug_offsets_validation.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ static_assert(
4848
PY_REMOTE_ASYNC_DEBUG_OFFSETS_TOTAL_SIZE,
4949
"Update _remote_debugging validation for _Py_AsyncioModuleDebugOffsets");
5050

51+
/* Derive unexported offsets from adjacent fields to keep the debug-offset
52+
* table compatible across patch releases. */
53+
static_assert(offsetof(PyThreadState, exc_info) ==
54+
offsetof(PyThreadState, current_exception) + sizeof(uintptr_t),
55+
"exc_info must immediately follow current_exception");
56+
static_assert(offsetof(_PyErr_StackItem, previous_item) ==
57+
offsetof(_PyErr_StackItem, exc_value) + sizeof(uintptr_t),
58+
"previous_item must immediately follow exc_value");
59+
5160
/*
5261
* This logic lives in a private header because it is shared by module.c and
5362
* asyncio.c. Keep the helpers static inline so they stay local to those users

‎Modules/_remote_debugging/threads.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@
2020
/* Bound traversal of corrupted remote exception chains. */
2121
#define MAX_EXCEPTION_CHAIN_DEPTH (2 << 15)
2222

23-
/* Derive unexported offsets from adjacent fields to keep the debug-offset
24-
* table compatible across patch releases. */
25-
static_assert(offsetof(PyThreadState, exc_info) ==
26-
offsetof(PyThreadState, current_exception) + sizeof(uintptr_t),
27-
"exc_info must immediately follow current_exception");
28-
static_assert(offsetof(_PyErr_StackItem, previous_item) ==
29-
offsetof(_PyErr_StackItem, exc_value) + sizeof(uintptr_t),
30-
"previous_item must immediately follow exc_value");
31-
3223
/* ============================================================================
3324
* THREAD ITERATION FUNCTIONS
3425
* ============================================================================ */

0 commit comments

Comments
 (0)