Skip to content

gh-91048: Prevent optimizing away the asyncio debug offsets structure on Windows #132963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we'd even do not need the __attribute__((used)) any longer in the GENERATE_DEBUG_SECTION macros.
But it doesn't hurt either - so let's keep it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I still prefer to keep it


} asyncio_state;

static inline asyncio_state *
Expand Down Expand Up @@ -4320,6 +4324,8 @@ module_init(asyncio_state *state)
goto fail;
}

state->debug_offsets = &_AsyncioDebug;

Py_DECREF(module);
return 0;

Expand Down
Loading