Skip to content

Commit a5e628b

Browse files
authored
gh-91048: Prevent optimizing away the asyncio debug offsets structure on Windows (#132963)
To avoid having the debug sections being optimised away by the compiler we use __attribute__((used)) on gcc and clang but in Windows this is not supported by the Microsoft compiler and there is no equivalent flag. Unfortunately Windows offers almost no alternative other than exporting the symbol in the dynamic table or using it somehow.
1 parent a1f4a6b commit a5e628b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Modules/_asynciomodule.c

+6
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ typedef struct {
185185
/* Counter for autogenerated Task names */
186186
uint64_t task_name_counter;
187187

188+
/* Pointer to the asyncio debug offset to avoid it to be optimized away
189+
by the compiler */
190+
void *debug_offsets;
191+
188192
} asyncio_state;
189193

190194
static inline asyncio_state *
@@ -4320,6 +4324,8 @@ module_init(asyncio_state *state)
43204324
goto fail;
43214325
}
43224326

4327+
state->debug_offsets = &_AsyncioDebug;
4328+
43234329
Py_DECREF(module);
43244330
return 0;
43254331

0 commit comments

Comments
 (0)