GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-100227: Port dup3_works to the module state variable. by corona10 · Pull Request #100262 · python/cpython

Conversation

@corona10

@corona10 corona10 commented Dec 15, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

dup3_works is safe to be ported as the module state variable since there is just one writing accessing in L9462.
Even if there are duplicated updatings for the dup3_works due to the race condition, dup3_works will not be updated anymore after the initial trial.

  • Issue: Improve Interpreter Isolation #100227

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@corona10
corona10 requested a review from ericsnowcurrently December 15, 2022 06:51
@bedevere-bot bedevere-bot mentioned this pull request Dec 15, 2022
Improve Interpreter Isolation #100227
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Dec 15, 2022
@netlify

netlify Bot commented Dec 15, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

✅ Deploy Preview for python-cpython-preview canceled.

Name Link
🔨 Latest commit 6ece310
🔍 Latest deploy log https://app.netlify.com/sites/python-cpython-preview/deploys/639ac64d32320a00083a23a6
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10
pythongh-100227: Port dup3_works to the module state variable.
c7a4761
@corona10
corona10 force-pushed the gh-100227 branch from e616a4c to c7a4761 Compare December 15, 2022 06:52
corona10 added 2 commits December 15, 2022 15:56
@corona10
fix
ba1d00a
@corona10
nit
6ece310
@ericsnowcurrently

ericsnowcurrently commented Dec 15, 2022

Copy link
Copy Markdown
Member

IMHO, we should keep all cached process-level resource availability/capability checks as static global variables. I'm specifically talking about the following group (and any others we might add in the future):

cpython/Tools/c-analyzer/cpython/ignored.tsv

Lines 16 to 23 in b7e4f1d

## indicators for resource availability/capability
# (set during first init)
Python/bootstrap_hash.c py_getrandom getrandom_works -
Python/fileutils.c - _Py_open_cloexec_works -
Python/fileutils.c set_inheritable ioctl_works -
# (set lazily, *after* first init)
# XXX Is this thread-safe?
Modules/posixmodule.c os_dup2_impl dup3_works -

Making any of them per-interpreter is unnecessary since the value will always be uniform for the process. Moving them to _PyRuntimeState did not seem correct because the value is independent of Python's runtime and should not change across init/fini cycles.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ericsnowcurrently

ericsnowcurrently commented Dec 15, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

tl;dr I'd rather we keep dup3_works as a static variable and not move it to the module state.

In the case of dup3_works the only concern I had was if there were any potential races, since the value is set lazily after runtime init. Looking at it again, there really isn't a race there. The only real race would be if two threads both see a -1 value (line 9463, if (dup3_works == -1)) and set the variable. However, that has no consequences if we assume word-size values like this are written atomically, which they should be. So let's not worry about it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10

corona10 commented Dec 16, 2022

Copy link
Copy Markdown
Member Author

In the case of dup3_works the only concern I had was if there were any potential races, since the value is set lazily after runtime init. Looking at it again, there really isn't a race there

Okay, I understood :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@corona10 corona10 closed this Dec 16, 2022
@ericsnowcurrently

ericsnowcurrently commented Dec 16, 2022

Copy link
Copy Markdown
Member

Thanks for working on this though!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jbosboom jbosboom mentioned this pull request Jul 6, 2025
gh-83714: Use statx on Linux 4.11 and later in os.stat #136334
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@corona10 @ericsnowcurrently @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.