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-149816: Fix a race condition in `_PyBytes_FromList` with free-threading by sobolevn · Pull Request #149909 · python/cpython

Conversation

@sobolevn

@sobolevn sobolevn commented May 16, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

_PyBytes_FromList is called from PyBytes_FromObject which does not own the passed object, so it is a borrowed reference.

Using _PyList_GetItemRef seems like the correct solution here.
However, I was not successful in actually triggering the failure without C-API direct usage.

  • Issue: 22 free-threading race conditions #149816

Sorry, something went wrong.

Uh oh!

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

All reactions
@sobolevn
pythongh-149816: Fix a race condition in _PyBytes_FromList with fre…
b2b19e2
…e-threading
@sobolevn
sobolevn requested a review from kumaraditya303 May 16, 2026 08:07
@bedevere-app bedevere-app Bot mentioned this pull request May 16, 2026
22 free-threading race conditions #149816
Open
13 of 24 tasks
@bedevere-app bedevere-app Bot added the awaiting core review label May 16, 2026
kumaraditya303
kumaraditya303 approved these changes May 16, 2026
View reviewed changes

@kumaraditya303 kumaraditya303 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 16, 2026
@sobolevn sobolevn added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels May 16, 2026
@sobolevn
sobolevn enabled auto-merge (squash) May 16, 2026 08:15
@sobolevn
sobolevn merged commit 46afba7 into python:main May 16, 2026
65 checks passed

Uh oh!

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

@miss-islington-app

miss-islington-app Bot commented May 16, 2026

Copy link
Copy Markdown

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label May 16, 2026
@miss-islington-app

miss-islington-app Bot commented May 16, 2026

Copy link
Copy Markdown

Sorry, @sobolevn, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 46afba7b9324bc9492c3527d0fe47dd74f1f598c 3.14
All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington-app miss-islington-app Bot assigned sobolevn May 16, 2026
@bedevere-app

bedevere-app Bot commented May 16, 2026

Copy link
Copy Markdown

GH-149911 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label May 16, 2026
@bedevere-app

bedevere-app Bot commented May 16, 2026

Copy link
Copy Markdown

GH-149912 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label May 16, 2026
@eendebakpt

eendebakpt commented May 16, 2026

Copy link
Copy Markdown
Contributor

@sobolevn @kumaraditya303 The same issue was addressed in #132590, which takes a different approach. Using Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST we can unify the tuple and list cases and improve performance. It also adds a FT test. Could you have a look at that PR please?

All reactions

Sorry, something went wrong.

Uh oh!

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

sobolevn added a commit that referenced this pull request May 16, 2026
@miss-islington @sobolevn
[3.15] gh-149816: Fix a race condition in _PyBytes_FromList with fr…
ec3aa6a
…ee-threading (GH-149909) (#149911)

gh-149816: Fix a race condition in `_PyBytes_FromList` with free-threading (GH-149909)
(cherry picked from commit 46afba7)

Co-authored-by: sobolevn <[email protected]>
@dzaramelcone dzaramelcone mentioned this pull request May 18, 2026
gh-149816: #96 Fix a race condition in invoke_gc_callback with free threading #150029
Merged
sobolevn added a commit that referenced this pull request May 21, 2026
@sobolevn
[3.14] gh-149816: Fix a race condition in _PyBytes_FromList with fr…
1d4f9ab
…ee-threading (GH-149909) (#149912)

(cherry picked from commit 46afba7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes

Uh oh!

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

Assignees

@sobolevn sobolevn

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.

3 participants

@sobolevn @eendebakpt @kumaraditya303
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.