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

gh-127065: Make methodcaller thread-safe in free threading build #127109

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Nov 21, 2024

The methodcaller C vectorcall implementation uses an arguments array that is shared across calls. The first argument is modified on every invocation. This isn't thread-safe in the free threading build. I think it's also not safe in general, but for now just disable it in the free threading build.

The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.
@mpage
Copy link
Contributor

mpage commented Nov 21, 2024

Would it be worth adding a regression test?

@colesbury
Copy link
Contributor Author

I think it'll be better to rely on something similar to pytest-run-parallel on test_operator.py, but I will add a test case if you prefer.

@mpage
Copy link
Contributor

mpage commented Nov 21, 2024

I think it'll be better to rely on something similar to pytest-run-parallel on test_operator.py

sgtm

@colesbury colesbury merged commit f83ca69 into python:main Nov 22, 2024
49 checks passed
@miss-islington-app
Copy link

Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@colesbury colesbury deleted the gh-127065-methodcaller branch November 22, 2024 14:22
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 22, 2024
…ild (pythonGH-127109)

The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.
(cherry picked from commit f83ca69)

Co-authored-by: Sam Gross <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Nov 22, 2024

GH-127150 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Nov 22, 2024
colesbury added a commit that referenced this pull request Nov 22, 2024
…uild (GH-127109) (GH-127150)

The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.
(cherry picked from commit f83ca69)

Co-authored-by: Sam Gross <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants