-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Abort in free-threaded build due to mutation of ChainMap of a Counter in threads
#126366
Comments
|
It looks like this is some sort of 3.14 regression. On 3.13, it doesn't crash; instead, it just spams This is probably a data race, but that scares me because nearly everything here is pure Python. Valgrind is pointing at native generators being the culprit, I'm looking into it. |
|
Yeah, there's a thread safety issue with native generators (or possibly with from threading import Thread
def my_generator():
for i in range(100000):
yield i
def main(gen):
list(gen)
gener = my_generator()
ts = [Thread(target=main, args=(gener,)) for _ in range(1000)]
for t in ts:
t.start()
for t in ts:
t.join() |
|
Yeah, Sam mentioned that in my (closed) PR. The main concern with merging gh-120327 is that it will have a heavy performance hit on generators. IIRC, the relation with generators in this issue is that |
What happened?
The code below, in a no-gil debug build with
PYTHON_GIL=0, results in the following abort:Found using fusil by @vstinner.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a1+ experimental free-threading build (heads/main:556dc9b8a7, Nov 3 2024, 10:09:47) [GCC 11.4.0]
Linked PRs
__iter__raises an exception duringyield from#126369The text was updated successfully, but these errors were encountered: