René's URL Explorer Experiment


Title: Data race in set iterator length_hint under no-gil · Issue #144356 · python/cpython · GitHub

Open Graph Title: Data race in set iterator length_hint under no-gil · Issue #144356 · python/cpython

X Title: Data race in set iterator length_hint under no-gil · Issue #144356 · python/cpython

Description: Bug report Build info $ cd cpython-tsan/bin/ $ ./python3.15 Python 3.15.0a5+ free-threading build (heads/main:96e4cd698a, Jan 31 2026, 11:45:37) [Clang 18.1.3 (1ubuntu1)] on linux Type "help", "copyright", "credits" or "license" for more...

Open Graph Description: Bug report Build info $ cd cpython-tsan/bin/ $ ./python3.15 Python 3.15.0a5+ free-threading build (heads/main:96e4cd698a, Jan 31 2026, 11:45:37) [Clang 18.1.3 (1ubuntu1)] on linux Type "help", "cop...

X Description: Bug report Build info $ cd cpython-tsan/bin/ $ ./python3.15 Python 3.15.0a5+ free-threading build (heads/main:96e4cd698a, Jan 31 2026, 11:45:37) [Clang 18.1.3 (1ubuntu1)] on linux Type "help&q...

Opengraph URL: https://github.com/python/cpython/issues/144356

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Data race in set iterator length_hint under no-gil","articleBody":"# Bug report\n\n### Build info\n``` bash\n$ cd cpython-tsan/bin/\n$ ./python3.15\nPython 3.15.0a5+ free-threading build (heads/main:96e4cd698a, Jan 31 2026, 11:45:37) [Clang 18.1.3 (1ubuntu1)] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n```\n### Bug description\n\nUnder `Py_GIL_DISABLED`, `setiter_len()` reads `so->used` non-atomically while concurrent set mutations update it atomically.\n\nThis triggers a data race detectable by TSAN when one thread repeatedly calls `iterator.__length_hint__()` while another mutates the same set\n\n#### Python script\n\n```python\nimport threading, time\n\ns = set(range(2000))\nit = iter(s)\nstop = threading.Event()\n\ndef reader():\n    while not stop.is_set():\n        it.__length_hint__()\n\ndef writer():\n    i = 0\n    while not stop.is_set():\n        s.add(i)\n        s.discard(i - 1)\n        i += 1\n\nthreads = [threading.Thread(target=reader) for _ in range(4)]\nthreads.append(threading.Thread(target=writer))\n\nfor t in threads: t.start()\ntime.sleep(3)\nstop.set()\nfor t in threads: t.join()\n```\n\n#### TSAN result\n\u003cdetails>\n\n``` bash\n$ TSAN_OPTIONS=\"halt_on_error=1:history_size=7:report_signal_unsafe=0:verbosity=1\" ./python3.15 ./tsan_setiter_len_race.py \n==1703386==WARNING: ThreadSanitizer: memory layout is incompatible, possibly due to high-entropy ASLR.\nRe-execing with fixed virtual address space.\nN.B. reducing ASLR entropy is preferable.\n==1703386==Installed the sigaction for signal 11\n==1703386==Installed the sigaction for signal 7\n==1703386==Installed the sigaction for signal 8\n***** Running under ThreadSanitizer v3 (pid 1703386) *****\n==================\nWARNING: ThreadSanitizer: data race (pid=1703386)\n  Atomic write of size 8 at 0x7fffb4395ce8 by thread T5:\n    #0 _Py_atomic_store_ssize_relaxed /home/hyongtao/worksapce/cpython/./Include/cpython/pyatomic_gcc.h:513:3 (python3.15+0x30378c) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #1 set_discard_entry /home/hyongtao/worksapce/cpython/Objects/setobject.c:594:5 (python3.15+0x30378c)\n    #2 set_discard_key /home/hyongtao/worksapce/cpython/Objects/setobject.c:630:12 (python3.15+0x30378c)\n    #3 set_discard_impl /home/hyongtao/worksapce/cpython/Objects/setobject.c:2616:10 (python3.15+0x30b3c3) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #4 set_discard /home/hyongtao/worksapce/cpython/Objects/clinic/setobject.c.h:502:20 (python3.15+0x30b3c3)\n    #5 _PyEval_EvalFrameDefault /home/hyongtao/worksapce/cpython/Python/generated_cases.c.h:4033:35 (python3.15+0x42abe4) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #6 _PyEval_EvalFrame /home/hyongtao/worksapce/cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15+0x41f890) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #7 _PyEval_Vector /home/hyongtao/worksapce/cpython/Python/ceval.c:2092:12 (python3.15+0x41f890)\n    #8 _PyFunction_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c (python3.15+0x20b85f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #9 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x20ff36) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #10 method_vectorcall /home/hyongtao/worksapce/cpython/Objects/classobject.c:73:20 (python3.15+0x20ff36)\n    #11 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x472d31) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #12 context_run /home/hyongtao/worksapce/cpython/Python/context.c:727:29 (python3.15+0x472d31)\n    #13 method_vectorcall_FASTCALL_KEYWORDS /home/hyongtao/worksapce/cpython/Objects/descrobject.c:421:24 (python3.15+0x224ab7) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #14 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x20b1e3) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #15 PyObject_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c:327:12 (python3.15+0x20b1e3)\n    #16 _Py_VectorCallInstrumentation_StackRefSteal /home/hyongtao/worksapce/cpython/Python/ceval.c:762:11 (python3.15+0x4204bc) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #17 _PyEval_EvalFrameDefault /home/hyongtao/worksapce/cpython/Python/generated_cases.c.h:1809:35 (python3.15+0x426376) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #18 _PyEval_EvalFrame /home/hyongtao/worksapce/cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15+0x41f890) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #19 _PyEval_Vector /home/hyongtao/worksapce/cpython/Python/ceval.c:2092:12 (python3.15+0x41f890)\n    #20 _PyFunction_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c (python3.15+0x20b85f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #21 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x20ff36) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #22 method_vectorcall /home/hyongtao/worksapce/cpython/Objects/classobject.c:73:20 (python3.15+0x20ff36)\n    #23 _PyVectorcall_Call /home/hyongtao/worksapce/cpython/Objects/call.c:273:16 (python3.15+0x20b4eb) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #24 _PyObject_Call /home/hyongtao/worksapce/cpython/Objects/call.c:348:16 (python3.15+0x20b4eb)\n    #25 PyObject_Call /home/hyongtao/worksapce/cpython/Objects/call.c:373:12 (python3.15+0x20b555) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #26 thread_run /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:387:21 (python3.15+0x5f12e2) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #27 pythread_wrapper /home/hyongtao/worksapce/cpython/Python/thread_pthread.h:234:5 (python3.15+0x522317) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n\n  Previous read of size 8 at 0x7fffb4395ce8 by thread T3:\n    #0 setiter_len /home/hyongtao/worksapce/cpython/Objects/setobject.c:1059:58 (python3.15+0x304ce9) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #1 _PyEval_EvalFrameDefault /home/hyongtao/worksapce/cpython/Python/generated_cases.c.h:3935:35 (python3.15+0x42a9d4) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #2 _PyEval_EvalFrame /home/hyongtao/worksapce/cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15+0x41f890) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #3 _PyEval_Vector /home/hyongtao/worksapce/cpython/Python/ceval.c:2092:12 (python3.15+0x41f890)\n    #4 _PyFunction_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c (python3.15+0x20b85f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #5 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x20ff36) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #6 method_vectorcall /home/hyongtao/worksapce/cpython/Objects/classobject.c:73:20 (python3.15+0x20ff36)\n    #7 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x472d31) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #8 context_run /home/hyongtao/worksapce/cpython/Python/context.c:727:29 (python3.15+0x472d31)\n    #9 method_vectorcall_FASTCALL_KEYWORDS /home/hyongtao/worksapce/cpython/Objects/descrobject.c:421:24 (python3.15+0x224ab7) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #10 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x20b1e3) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #11 PyObject_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c:327:12 (python3.15+0x20b1e3)\n    #12 _Py_VectorCallInstrumentation_StackRefSteal /home/hyongtao/worksapce/cpython/Python/ceval.c:762:11 (python3.15+0x4204bc) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #13 _PyEval_EvalFrameDefault /home/hyongtao/worksapce/cpython/Python/generated_cases.c.h:1809:35 (python3.15+0x426376) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #14 _PyEval_EvalFrame /home/hyongtao/worksapce/cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15+0x41f890) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #15 _PyEval_Vector /home/hyongtao/worksapce/cpython/Python/ceval.c:2092:12 (python3.15+0x41f890)\n    #16 _PyFunction_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c (python3.15+0x20b85f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #17 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:136:11 (python3.15+0x20ff36) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #18 method_vectorcall /home/hyongtao/worksapce/cpython/Objects/classobject.c:73:20 (python3.15+0x20ff36)\n    #19 _PyVectorcall_Call /home/hyongtao/worksapce/cpython/Objects/call.c:273:16 (python3.15+0x20b4eb) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #20 _PyObject_Call /home/hyongtao/worksapce/cpython/Objects/call.c:348:16 (python3.15+0x20b4eb)\n    #21 PyObject_Call /home/hyongtao/worksapce/cpython/Objects/call.c:373:12 (python3.15+0x20b555) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #22 thread_run /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:387:21 (python3.15+0x5f12e2) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #23 pythread_wrapper /home/hyongtao/worksapce/cpython/Python/thread_pthread.h:234:5 (python3.15+0x522317) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n\n  Thread T5 'Thread-5 (write' (tid=1703392, running) created by main thread at:\n    #0 pthread_create \u003cnull> (python3.15+0xf421f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #1 do_start_joinable_thread /home/hyongtao/worksapce/cpython/Python/thread_pthread.h:281:14 (python3.15+0x521424) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #2 PyThread_start_joinable_thread /home/hyongtao/worksapce/cpython/Python/thread_pthread.h:323:9 (python3.15+0x52123a) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #3 ThreadHandle_start /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:474:9 (python3.15+0x5f109a) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #4 do_start_new_thread /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:1920:9 (python3.15+0x5f0b3f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #5 thread_PyThread_start_joinable_thread /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:2043:14 (python3.15+0x5efc01) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #6 cfunction_call /home/hyongtao/worksapce/cpython/Objects/methodobject.c:564:18 (python3.15+0x2bab87) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #7 _PyObject_MakeTpCall /home/hyongtao/worksapce/cpython/Objects/call.c:242:18 (python3.15+0x20a68f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #8 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:134:16 (python3.15+0x20b2a7) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #9 PyObject_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c:327:12 (python3.15+0x20b2a7)\n    #10 _Py_VectorCall_StackRefSteal /home/hyongtao/worksapce/cpython/Python/ceval.c:720:11 (python3.15+0x41fce9) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #11 _PyEval_EvalFrameDefault /home/hyongtao/worksapce/cpython/Python/generated_cases.c.h:3387:35 (python3.15+0x429c79) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #12 _PyEval_EvalFrame /home/hyongtao/worksapce/cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15+0x41f3b0) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #13 _PyEval_Vector /home/hyongtao/worksapce/cpython/Python/ceval.c:2092:12 (python3.15+0x41f3b0)\n    #14 PyEval_EvalCode /home/hyongtao/worksapce/cpython/Python/ceval.c:673:21 (python3.15+0x41f3b0)\n    #15 run_eval_code_obj /home/hyongtao/worksapce/cpython/Python/pythonrun.c:1366:12 (python3.15+0x4fe967) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #16 run_mod /home/hyongtao/worksapce/cpython/Python/pythonrun.c:1469:19 (python3.15+0x4fe967)\n    #17 pyrun_file /home/hyongtao/worksapce/cpython/Python/pythonrun.c:1294:15 (python3.15+0x4f9d13) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #18 _PyRun_SimpleFileObject /home/hyongtao/worksapce/cpython/Python/pythonrun.c:518:13 (python3.15+0x4f9d13)\n    #19 _PyRun_AnyFileObject /home/hyongtao/worksapce/cpython/Python/pythonrun.c:81:15 (python3.15+0x4f9498) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #20 pymain_run_file_obj /home/hyongtao/worksapce/cpython/Modules/main.c:410:15 (python3.15+0x53bedf) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #21 pymain_run_file /home/hyongtao/worksapce/cpython/Modules/main.c:429:15 (python3.15+0x53bedf)\n    #22 pymain_run_python /home/hyongtao/worksapce/cpython/Modules/main.c:691:21 (python3.15+0x53b20b) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #23 Py_RunMain /home/hyongtao/worksapce/cpython/Modules/main.c:772:5 (python3.15+0x53b20b)\n    #24 pymain_main /home/hyongtao/worksapce/cpython/Modules/main.c:802:12 (python3.15+0x53b778) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #25 Py_BytesMain /home/hyongtao/worksapce/cpython/Modules/main.c:826:12 (python3.15+0x53b7fb) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #26 main /home/hyongtao/worksapce/cpython/./Programs/python.c:15:12 (python3.15+0x17282b) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n\n  Thread T3 'Thread-3 (reade' (tid=1703390, running) created by main thread at:\n    #0 pthread_create \u003cnull> (python3.15+0xf421f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #1 do_start_joinable_thread /home/hyongtao/worksapce/cpython/Python/thread_pthread.h:281:14 (python3.15+0x521424) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #2 PyThread_start_joinable_thread /home/hyongtao/worksapce/cpython/Python/thread_pthread.h:323:9 (python3.15+0x52123a) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #3 ThreadHandle_start /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:474:9 (python3.15+0x5f109a) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #4 do_start_new_thread /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:1920:9 (python3.15+0x5f0b3f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #5 thread_PyThread_start_joinable_thread /home/hyongtao/worksapce/cpython/./Modules/_threadmodule.c:2043:14 (python3.15+0x5efc01) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #6 cfunction_call /home/hyongtao/worksapce/cpython/Objects/methodobject.c:564:18 (python3.15+0x2bab87) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #7 _PyObject_MakeTpCall /home/hyongtao/worksapce/cpython/Objects/call.c:242:18 (python3.15+0x20a68f) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #8 _PyObject_VectorcallTstate /home/hyongtao/worksapce/cpython/./Include/internal/pycore_call.h:134:16 (python3.15+0x20b2a7) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #9 PyObject_Vectorcall /home/hyongtao/worksapce/cpython/Objects/call.c:327:12 (python3.15+0x20b2a7)\n    #10 _Py_VectorCall_StackRefSteal /home/hyongtao/worksapce/cpython/Python/ceval.c:720:11 (python3.15+0x41fce9) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #11 _PyEval_EvalFrameDefault /home/hyongtao/worksapce/cpython/Python/generated_cases.c.h:3387:35 (python3.15+0x429c79) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #12 _PyEval_EvalFrame /home/hyongtao/worksapce/cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15+0x41f3b0) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #13 _PyEval_Vector /home/hyongtao/worksapce/cpython/Python/ceval.c:2092:12 (python3.15+0x41f3b0)\n    #14 PyEval_EvalCode /home/hyongtao/worksapce/cpython/Python/ceval.c:673:21 (python3.15+0x41f3b0)\n    #15 run_eval_code_obj /home/hyongtao/worksapce/cpython/Python/pythonrun.c:1366:12 (python3.15+0x4fe967) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #16 run_mod /home/hyongtao/worksapce/cpython/Python/pythonrun.c:1469:19 (python3.15+0x4fe967)\n    #17 pyrun_file /home/hyongtao/worksapce/cpython/Python/pythonrun.c:1294:15 (python3.15+0x4f9d13) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #18 _PyRun_SimpleFileObject /home/hyongtao/worksapce/cpython/Python/pythonrun.c:518:13 (python3.15+0x4f9d13)\n    #19 _PyRun_AnyFileObject /home/hyongtao/worksapce/cpython/Python/pythonrun.c:81:15 (python3.15+0x4f9498) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #20 pymain_run_file_obj /home/hyongtao/worksapce/cpython/Modules/main.c:410:15 (python3.15+0x53bedf) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #21 pymain_run_file /home/hyongtao/worksapce/cpython/Modules/main.c:429:15 (python3.15+0x53bedf)\n    #22 pymain_run_python /home/hyongtao/worksapce/cpython/Modules/main.c:691:21 (python3.15+0x53b20b) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #23 Py_RunMain /home/hyongtao/worksapce/cpython/Modules/main.c:772:5 (python3.15+0x53b20b)\n    #24 pymain_main /home/hyongtao/worksapce/cpython/Modules/main.c:802:12 (python3.15+0x53b778) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #25 Py_BytesMain /home/hyongtao/worksapce/cpython/Modules/main.c:826:12 (python3.15+0x53b7fb) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n    #26 main /home/hyongtao/worksapce/cpython/./Programs/python.c:15:12 (python3.15+0x17282b) (BuildId: 00135b3b874b2f13c2b74122623dcba7b1b9ce4a)\n\nSUMMARY: ThreadSanitizer: data race /home/hyongtao/worksapce/cpython/./Include/cpython/pyatomic_gcc.h:513:3 in _Py_atomic_store_ssize_relaxed\n==================\n\n```\n\n\u003c/details>\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-144357\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/hyongtao-code","@type":"Person","name":"hyongtao-code"},"datePublished":"2026-01-31T03:30:04Z","url":"https://github.com/python/cpython/issues/144356"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:49e6de2a-a801-3217-510a-c41972da32f1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDAD2:27E5CD:3C94A2E:4D6D5C2:6B020210
html-safe-nonce9e7623204e6a7819d7500d7f7f3d3ec629375ccef17c7195d5ea91fd6a56f54d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUQyOjI3RTVDRDozQzk0QTJFOjRENkQ1QzI6NkIwMjAyMTAiLCJ2aXNpdG9yX2lkIjoiNjc3MjMxOTkzNDY2NTA2NDk3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4fa576269a3a07c11f13c476d2ab4ad9e4c458fd10db5883e93ae542ff7f681e
hovercard-subject-tagissue:3878257240
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/144356/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ea45185237b88079f5eeb1510bcdc1c5a8a795353cadee465b60187a4babe0d3/python/cpython/issues/144356
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ea45185237b88079f5eeb1510bcdc1c5a8a795353cadee465b60187a4babe0d3/python/cpython/issues/144356
og:image:altBug report Build info $ cd cpython-tsan/bin/ $ ./python3.15 Python 3.15.0a5+ free-threading build (heads/main:96e4cd698a, Jan 31 2026, 11:45:37) [Clang 18.1.3 (1ubuntu1)] on linux Type "help", "cop...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamehyongtao-code
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/144356#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F144356
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F144356
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/144356
Reloadhttps://github.com/python/cpython/issues/144356
Reloadhttps://github.com/python/cpython/issues/144356
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/144356
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/144356
Data race in set iterator length_hint under no-gilhttps://github.com/python/cpython/issues/144356#top
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/hyongtao-code
hyongtao-codehttps://github.com/hyongtao-code
on Jan 31, 2026https://github.com/python/cpython/issues/144356#issue-3878257240
gh-144356: Make set iterator __length_hint__ and iternext race-safe under no-gil #144357https://github.com/python/cpython/pull/144357
hyongtao-codehttps://github.com/hyongtao-code
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Jan 31, 2026https://github.com/python/cpython/issues/144356#event-22423644744
aiskhttps://github.com/aisk
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
on Jan 31, 2026https://github.com/python/cpython/issues/144356#event-22424147153
https://github.com/devdanzin
devdanzinhttps://github.com/devdanzin
on Jul 19, 2026https://github.com/python/cpython/issues/144356#issuecomment-5013810608
#144357https://github.com/python/cpython/pull/144357
https://github.com/devdanzin
devdanzinhttps://github.com/devdanzin
on Jul 20, 2026https://github.com/python/cpython/issues/144356#issuecomment-5018014882
#144357https://github.com/python/cpython/pull/144357
gh-154130https://github.com/python/cpython/issues/154130
kumaraditya303https://github.com/kumaraditya303
on Nov 20, 2026https://github.com/python/cpython/issues/144356#event-36769516684
Keep the set reference until dealloc in free-threaded set iteratorshttps://github.com/scrieve/cpython/commit/909027cc97ca1e41f7bb2b7e00dfce27de841360
909027chttps://github.com/scrieve/cpython/commit/909027cc97ca1e41f7bb2b7e00dfce27de841360
kumaraditya303https://github.com/kumaraditya303
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 20, 2026https://github.com/python/cpython/issues/144356#event-36782691161
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/144356
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/144356
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.