]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91048: Prevent optimizing away the asyncio debug offsets structure on Windows...
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Fri, 25 Apr 2025 17:43:32 +0000 (18:43 +0100)
committerGitHub <noreply@github.com>
Fri, 25 Apr 2025 17:43:32 +0000 (17:43 +0000)
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.

Modules/_asynciomodule.c

index 27e6e67e3c9386c0ae5a095b337266f57b052424..5f9181395c4828cd2b5e1036f64111ccda292ec5 100644 (file)
@@ -185,6 +185,10 @@ typedef struct {
     /* Counter for autogenerated Task names */
     uint64_t task_name_counter;
 
+    /* Pointer to the asyncio debug offset to avoid it to be optimized away
+       by the compiler */
+    void *debug_offsets;
+
 } asyncio_state;
 
 static inline asyncio_state *
@@ -4320,6 +4324,8 @@ module_init(asyncio_state *state)
         goto fail;
     }
 
+    state->debug_offsets = &_AsyncioDebug;
+
     Py_DECREF(module);
     return 0;