Skip to content
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

socketmodule.c: use atomics to access defaulttimeout in free-threaded build #116616

Closed
Tracked by #116738 ...
colesbury opened this issue Mar 11, 2024 · 0 comments · Fixed by #116623
Closed
Tracked by #116738 ...

socketmodule.c: use atomics to access defaulttimeout in free-threaded build #116616

colesbury opened this issue Mar 11, 2024 · 0 comments · Fixed by #116623
Labels
extension-modules C modules in the Modules dir topic-free-threading type-feature A feature request or enhancement

Comments

@colesbury
Copy link
Contributor

colesbury commented Mar 11, 2024

Feature or enhancement

The defaulttimeout in socketmodule.c is shared, mutable state:

PyTime_t defaulttimeout;

In the free-threaded build, we should use relaxed atomic operations to access defaulttimeout to avoid data races. This probably requires adding wrappers for 64-bit relaxed atomic load and stores to https://github.com/python/cpython/blob/main/Include/internal/pycore_pyatomic_ft_wrappers.h. Note that _PyTime_t is a typedef for int64_t.

For context, here is a similar change from nogil-3.12, but note that defaulttimeout is now part of the module state:

Linked PRs

@colesbury colesbury added type-feature A feature request or enhancement topic-free-threading labels Mar 11, 2024
@colesbury colesbury changed the title socketmodule.c should use atomics to access defaulttimeout in free-threaded build socketmodule.c should use atomics to access defaulttimeout in free-threaded build Mar 11, 2024
@colesbury colesbury changed the title socketmodule.c should use atomics to access defaulttimeout in free-threaded build socketmodule.c: use atomics to access defaulttimeout in free-threaded build Mar 11, 2024
@Eclips4 Eclips4 added the extension-modules C modules in the Modules dir label Mar 11, 2024
erlend-aasland pushed a commit to erlend-aasland/cpython that referenced this issue Mar 11, 2024
erlend-aasland added a commit that referenced this issue Mar 12, 2024
…out (#116623)

Co-authored-by: Sam Gross <colesbury@gmail.com>
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
…lttimeout (python#116623)

Co-authored-by: Sam Gross <colesbury@gmail.com>
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…lttimeout (python#116623)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir topic-free-threading type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants