Skip to content

Commit 4e99743

Browse files
committed
gh-91048: Prevent optimizing away the asyncio debug offsets structure on Windows
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 17718b0 commit 4e99743

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Modules/_asynciomodule.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ typedef struct {
185185
/* Counter for autogenerated Task names */
186186
uint64_t task_name_counter;
187187

188+
#ifdef MS_WINDOWS
189+
/* Pointer to the asyncio debug offset to avoid it to be optimized away
190+
by the compiler in Windows (other platforms don't need this) */
191+
void *debug_offsets;
192+
#endif
193+
188194
} asyncio_state;
189195

190196
static inline asyncio_state *
@@ -4320,6 +4326,10 @@ module_init(asyncio_state *state)
43204326
goto fail;
43214327
}
43224328

4329+
#ifdef MS_WINDOWS
4330+
state->debug_offsets = &_AsyncioDebug;
4331+
#endif
4332+
43234333
Py_DECREF(module);
43244334
return 0;
43254335

0 commit comments

Comments
 (0)