python / cpython

The Python programming language
https://www.python.org
Other
63.65k stars 30.49k forks source link

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

Closed colesbury closed 3 days ago

colesbury commented 4 days ago

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 commented 4 days ago

Would it be worth adding a regression test?

colesbury commented 4 days ago

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 commented 4 days ago

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

sgtm

miss-islington-app[bot] commented 3 days ago

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

bedevere-app[bot] commented 3 days ago

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