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-59956: Partial Fix for GILState API Compatibility with Subinterpreters by ericsnowcurrently · Pull Request #101431 · python/cpython

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Jan 30, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

The GILState API (PEP 311) implementation from 2003 made the assumption that only one thread state would ever be used for any given OS thread, explicitly disregarding the case of subinterpreters. However, PyThreadState_Swap() still facilitated switching between subinterpreters, meaning the "current" thread state (holding the GIL), and the GILState thread state could end up out of sync, causing problems (including crashes).

This change addresses the issue by keeping the two in sync in PyThreadState_Swap(). I verified the fix against gh-99040.

Note that the other GILState-subinterpreter incompatibility (with autoInterpreterState) is not resolved here.

  • Issue: [subinterpreters] Make the PyGILState API compatible with subinterpreters #59956

Sorry, something went wrong.

Uh oh!

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

All reactions
ericsnowcurrently added 3 commits January 30, 2023 12:08
@ericsnowcurrently
Swap the "auto TSS" tstate too.
f9e6b8d
@ericsnowcurrently
Do not bail out in bind_gilstate_tstate() if it's already set.
3e8c3ef
@ericsnowcurrently
Add a NEWS entry.
631c872
@bedevere-bot bedevere-bot added the awaiting core review label Jan 30, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jan 30, 2023
[subinterpreters] Make the PyGILState API compatible with subinterpreters #59956
Open
@ericsnowcurrently ericsnowcurrently mentioned this pull request Jan 30, 2023
Segmentation fault during the test__xxsubinterpreters test #100981
Closed
@ericsnowcurrently

ericsnowcurrently commented Feb 2, 2023

Copy link
Copy Markdown
Member Author

@pitrou, do you have any objections to this fix?

All reactions

Sorry, something went wrong.

Uh oh!

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

@ericsnowcurrently
ericsnowcurrently merged commit 132b3f8 into python:main Feb 6, 2023
@bedevere-bot bedevere-bot removed the awaiting core review label Feb 6, 2023
@ericsnowcurrently
ericsnowcurrently deleted the gilstate-fixes-for-subinterpreters-3 branch February 6, 2023 21:39
@ericsnowcurrently ericsnowcurrently mentioned this pull request Feb 6, 2023
gh-59956: Add a Test to Verify GILState Matches the "Current" Thread State #101625
Merged
ericsnowcurrently added a commit that referenced this pull request Feb 6, 2023
@ericsnowcurrently
gh-59956: Add a Test to Verify GILState Matches the "Current" Thread …
914f8fd
…State (gh-101625)

This test should have been in gh-101431.

#59956
@AlexanderWells-diamond AlexanderWells-diamond mentioned this pull request Jun 27, 2025
Using latest cothread on python3.11 with pyqt results in segfault DiamondLightSource/cothread#75
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

2 participants

@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.