Skip to content

Generator already executing free-threaded crashes #135325

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

Closed
Dobatymo opened this issue Jun 10, 2025 · 1 comment
Closed

Generator already executing free-threaded crashes #135325

Dobatymo opened this issue Jun 10, 2025 · 1 comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@Dobatymo
Copy link
Contributor

Dobatymo commented Jun 10, 2025

Crash report

What happened?

When running the following code snipped a few times, I can cause two different windows exceptions. And also the expected ValueError: generator already executing.

from threading import Thread

def inner(it):
    for _i in it:
        pass

def main():
    it = (i for i in range(100000))
    t1 = Thread(target=inner, args=(it,))
    t2 = Thread(target=inner, args=(it,))
    t1.start()
    t2.start()
    t1.join()
    t2.join()

if __name__ == "__main__":
    main()
    print("success")
Assertion failed: (gen->gi_frame_state == FRAME_CREATED) || FRAME_STATE_SUSPENDED(gen->gi_frame_state), file ...\cpython\Objects\genobject.c, line 242
Windows fatal exception: code 0x80000003

<Cannot show all threads while the GIL is disabled>
Stack (most recent call first):
  File "...\t_iter.py", line 7 in inner
  File "...\cpython\Lib\threading.py", line 1016 in run
  File "...\cpython\Lib\threading.py", line 1074 in _bootstrap_inner
  File "...\cpython\Lib\threading.py", line 1036 in _bootstrap

Current thread's C stack trace (most recent call first):
  <cannot get C stack on this system>
Windows fatal exception: access violation

Assertion failed: frame->stackpointer != NULL, file ...\cpython\Include\internal\pycore_interpframe.h, line 173
<Cannot show all threads while the GIL is disabled>
Stack (most recent call first):
  File "...\t_iter.py", line 12 in <genexpr>
  File "...\t_iter.py", line 7 in inner
  File "...\cpython\Lib\threading.py", line 1016 in run
  File "...\cpython\Lib\threading.py", line 1074 in _bootstrap_inner
  File "...\cpython\Lib\threading.py", line 1036 in _bootstrap

Current thread's C stack trace (most recent call first):
  <cannot get C stack on this system>

Not sure why it cannot get the C stack. I used the current main branch to compile a debug build. The -VV string shows a custom branch, but it doesn't include any changes.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Output from running 'python -VV' on the command line:

Python 3.15.0a0 experimental free-threading build (heads/fix-thread-crash-dirty:2e1544fd2b0, Jun 5 2025, 16:53:09) [MSC v.1944 64 bit (AMD64)]

@Dobatymo Dobatymo added the type-crash A hard crash of the interpreter, possibly with a core dump label Jun 10, 2025
@kumaraditya303
Copy link
Contributor

I closed this as it is a duplicate of #120321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

2 participants