FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-117657: Make frame clearing thread-safe by Fidget-Spinner · Pull Request #120542 · python/cpython · GitHub

/ cpython Public

gh-117657: Make frame clearing thread-safe - #120542

Closed
Fidget-Spinner wants to merge 5 commits into
python:mainfrom
Fidget-Spinner:frame_tp_clear
Closed

gh-117657: Make frame clearing thread-safe#120542
Fidget-Spinner wants to merge 5 commits into
python:mainfrom
Fidget-Spinner:frame_tp_clear

Conversation

Fidget-Spinner commented Jun 15, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Data race reported by TSAN on the test:

==================
WARNING: ThreadSanitizer: data race (pid=58102)
  Write of size 4 at 0x7fffb4922638 by thread T1:
    #0 frame_tp_clear /home/ken/Documents/GitHub/cpython/Objects/frameobject.c:1659:26 (python+0x2a6c43) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #1 frame_clear /home/ken/Documents/GitHub/cpython/Objects/frameobject.c:1682:15 (python+0x2ac64c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #2 method_vectorcall_NOARGS /home/ken/Documents/GitHub/cpython/Objects/descrobject.c:447:24 (python+0x275080) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #3 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x2589c1) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #4 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #5 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #6 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #7 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #8 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #9 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #10 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:70:20 (python+0x25ef55) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #11 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #12 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #13 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #14 thread_run /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:337:21 (python+0x6a2648) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #15 pythread_wrapper /home/ken/Documents/GitHub/cpython/Python/thread_pthread.h:243:5 (python+0x5ddd7b) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)

  Previous write of size 4 at 0x7fffb4922638 by thread T2:
    #0 frame_tp_clear /home/ken/Documents/GitHub/cpython/Objects/frameobject.c:1659:26 (python+0x2a6c43) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #1 frame_clear /home/ken/Documents/GitHub/cpython/Objects/frameobject.c:1682:15 (python+0x2ac64c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #2 method_vectorcall_NOARGS /home/ken/Documents/GitHub/cpython/Objects/descrobject.c:447:24 (python+0x275080) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #3 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x2589c1) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #4 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #5 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #6 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #7 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #8 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #9 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #10 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:70:20 (python+0x25ef55) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #11 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #12 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #13 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #14 thread_run /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:337:21 (python+0x6a2648) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #15 pythread_wrapper /home/ken/Documents/GitHub/cpython/Python/thread_pthread.h:243:5 (python+0x5ddd7b) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)

  Thread T1 (tid=58105, running) created by main thread at:
    #0 pthread_create <null> (python+0xdd37b) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #1 do_start_joinable_thread /home/ken/Documents/GitHub/cpython/Python/thread_pthread.h:290:14 (python+0x5dc9eb) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #2 PyThread_start_joinable_thread /home/ken/Documents/GitHub/cpython/Python/thread_pthread.h:314:9 (python+0x5dc80a) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #3 ThreadHandle_start /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:422:9 (python+0x6a214f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #4 do_start_new_thread /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:1798:9 (python+0x6a214f)
    #5 thread_PyThread_start_joinable_thread /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:1921:14 (python+0x6a0ba5) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #6 cfunction_call /home/ken/Documents/GitHub/cpython/Objects/methodobject.c:540:18 (python+0x31a189) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #7 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #8 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #9 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #10 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1505:19 (python+0x4a5e53) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #11 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #12 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #13 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #14 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #15 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:92:18 (python+0x25efc2) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #16 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #17 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #18 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #19 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1358:26 (python+0x4a4c61) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #20 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #21 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #22 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #23 _PyObject_VectorcallDictTstate /home/ken/Documents/GitHub/cpython/Objects/call.c:135:15 (python+0x258c83) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #24 _PyObject_Call_Prepend /home/ken/Documents/GitHub/cpython/Objects/call.c:504:24 (python+0x25af46) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #25 slot_tp_call /home/ken/Documents/GitHub/cpython/Objects/typeobject.c:9730:15 (python+0x397e8c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #26 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #27 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #28 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #29 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #30 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #31 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #32 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #33 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #34 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:92:18 (python+0x25efc2) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #35 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #36 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #37 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #38 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1358:26 (python+0x4a4c61) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #39 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #40 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #41 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #42 _PyObject_VectorcallDictTstate /home/ken/Documents/GitHub/cpython/Objects/call.c:135:15 (python+0x258c83) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #43 _PyObject_Call_Prepend /home/ken/Documents/GitHub/cpython/Objects/call.c:504:24 (python+0x25af46) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #44 slot_tp_call /home/ken/Documents/GitHub/cpython/Objects/typeobject.c:9730:15 (python+0x397e8c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #45 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #46 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #47 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #48 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #49 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #50 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #51 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #52 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #53 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:92:18 (python+0x25efc2) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #54 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #55 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #56 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #57 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1358:26 (python+0x4a4c61) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #58 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #59 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #60 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #61 _PyObject_VectorcallDictTstate /home/ken/Documents/GitHub/cpython/Objects/call.c:135:15 (python+0x258c83) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #62 _PyObject_Call_Prepend /home/ken/Documents/GitHub/cpython/Objects/call.c:504:24 (python+0x25af46) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #63 slot_tp_call /home/ken/Documents/GitHub/cpython/Objects/typeobject.c:9730:15 (python+0x397e8c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #64 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #65 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #66 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #67 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #68 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #69 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #70 PyEval_EvalCode /home/ken/Documents/GitHub/cpython/Python/ceval.c:599:21 (python+0x49b48a) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #71 builtin_exec_impl /home/ken/Documents/GitHub/cpython/Python/bltinmodule.c:1145:17 (python+0x493873) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #72 builtin_exec /home/ken/Documents/GitHub/cpython/Python/clinic/bltinmodule.c.h:556:20 (python+0x493873)
    #73 cfunction_vectorcall_FASTCALL_KEYWORDS /home/ken/Documents/GitHub/cpython/Objects/methodobject.c:441:24 (python+0x318c4c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #74 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x2589c1) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #75 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #76 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #77 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #78 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #79 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #80 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #81 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #82 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #83 pymain_run_module /home/ken/Documents/GitHub/cpython/Modules/main.c:297:14 (python+0x5f9ab3) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #84 pymain_run_python /home/ken/Documents/GitHub/cpython/Modules/main.c (python+0x5f91cb) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #85 Py_RunMain /home/ken/Documents/GitHub/cpython/Modules/main.c:719:5 (python+0x5f91cb)
    #86 pymain_main /home/ken/Documents/GitHub/cpython/Modules/main.c:749:12 (python+0x5f9859) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #87 Py_BytesMain /home/ken/Documents/GitHub/cpython/Modules/main.c:773:12 (python+0x5f98d9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #88 main /home/ken/Documents/GitHub/cpython/./Programs/python.c:15:12 (python+0x15a840) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)

  Thread T2 (tid=58106, running) created by main thread at:
    #0 pthread_create <null> (python+0xdd37b) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #1 do_start_joinable_thread /home/ken/Documents/GitHub/cpython/Python/thread_pthread.h:290:14 (python+0x5dc9eb) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #2 PyThread_start_joinable_thread /home/ken/Documents/GitHub/cpython/Python/thread_pthread.h:314:9 (python+0x5dc80a) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #3 ThreadHandle_start /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:422:9 (python+0x6a214f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #4 do_start_new_thread /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:1798:9 (python+0x6a214f)
    #5 thread_PyThread_start_joinable_thread /home/ken/Documents/GitHub/cpython/./Modules/_threadmodule.c:1921:14 (python+0x6a0ba5) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #6 cfunction_call /home/ken/Documents/GitHub/cpython/Objects/methodobject.c:540:18 (python+0x31a189) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #7 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #8 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #9 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #10 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1505:19 (python+0x4a5e53) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #11 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #12 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #13 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #14 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #15 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:92:18 (python+0x25efc2) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #16 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #17 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #18 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #19 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1358:26 (python+0x4a4c61) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #20 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #21 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #22 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #23 _PyObject_VectorcallDictTstate /home/ken/Documents/GitHub/cpython/Objects/call.c:135:15 (python+0x258c83) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #24 _PyObject_Call_Prepend /home/ken/Documents/GitHub/cpython/Objects/call.c:504:24 (python+0x25af46) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #25 slot_tp_call /home/ken/Documents/GitHub/cpython/Objects/typeobject.c:9730:15 (python+0x397e8c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #26 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #27 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #28 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #29 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #30 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #31 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #32 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #33 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #34 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:92:18 (python+0x25efc2) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #35 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #36 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #37 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #38 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1358:26 (python+0x4a4c61) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #39 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #40 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #41 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #42 _PyObject_VectorcallDictTstate /home/ken/Documents/GitHub/cpython/Objects/call.c:135:15 (python+0x258c83) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #43 _PyObject_Call_Prepend /home/ken/Documents/GitHub/cpython/Objects/call.c:504:24 (python+0x25af46) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #44 slot_tp_call /home/ken/Documents/GitHub/cpython/Objects/typeobject.c:9730:15 (python+0x397e8c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #45 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #46 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #47 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #48 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #49 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #50 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #51 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #52 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x260c31) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #53 method_vectorcall /home/ken/Documents/GitHub/cpython/Objects/classobject.c:92:18 (python+0x25efc2) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #54 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #55 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #56 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #57 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:1358:26 (python+0x4a4c61) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #58 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #59 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #60 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #61 _PyObject_VectorcallDictTstate /home/ken/Documents/GitHub/cpython/Objects/call.c:135:15 (python+0x258c83) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #62 _PyObject_Call_Prepend /home/ken/Documents/GitHub/cpython/Objects/call.c:504:24 (python+0x25af46) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #63 slot_tp_call /home/ken/Documents/GitHub/cpython/Objects/typeobject.c:9730:15 (python+0x397e8c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #64 _PyObject_MakeTpCall /home/ken/Documents/GitHub/cpython/Objects/call.c:242:18 (python+0x259183) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #65 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:166:16 (python+0x2589e9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #66 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #67 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #68 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #69 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #70 PyEval_EvalCode /home/ken/Documents/GitHub/cpython/Python/ceval.c:599:21 (python+0x49b48a) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #71 builtin_exec_impl /home/ken/Documents/GitHub/cpython/Python/bltinmodule.c:1145:17 (python+0x493873) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #72 builtin_exec /home/ken/Documents/GitHub/cpython/Python/clinic/bltinmodule.c.h:556:20 (python+0x493873)
    #73 cfunction_vectorcall_FASTCALL_KEYWORDS /home/ken/Documents/GitHub/cpython/Objects/methodobject.c:441:24 (python+0x318c4c) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #74 _PyObject_VectorcallTstate /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_call.h:168:11 (python+0x2589c1) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #75 PyObject_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c:327:12 (python+0x25a590) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #76 _PyEval_EvalFrameDefault /home/ken/Documents/GitHub/cpython/Python/generated_cases.c.h:813:23 (python+0x4a1732) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #77 _PyEval_EvalFrame /home/ken/Documents/GitHub/cpython/./Include/internal/pycore_ceval.h:119:16 (python+0x49b823) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #78 _PyEval_Vector /home/ken/Documents/GitHub/cpython/Python/ceval.c:1819:12 (python+0x49b823)
    #79 _PyFunction_Vectorcall /home/ken/Documents/GitHub/cpython/Objects/call.c (python+0x25aabe) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #80 _PyVectorcall_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:273:16 (python+0x25a45f) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #81 _PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:348:16 (python+0x25a6f7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #82 PyObject_Call /home/ken/Documents/GitHub/cpython/Objects/call.c:373:12 (python+0x25a8e7) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #83 pymain_run_module /home/ken/Documents/GitHub/cpython/Modules/main.c:297:14 (python+0x5f9ab3) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #84 pymain_run_python /home/ken/Documents/GitHub/cpython/Modules/main.c (python+0x5f91cb) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #85 Py_RunMain /home/ken/Documents/GitHub/cpython/Modules/main.c:719:5 (python+0x5f91cb)
    #86 pymain_main /home/ken/Documents/GitHub/cpython/Modules/main.c:749:12 (python+0x5f9859) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #87 Py_BytesMain /home/ken/Documents/GitHub/cpython/Modules/main.c:773:12 (python+0x5f98d9) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)
    #88 main /home/ken/Documents/GitHub/cpython/./Programs/python.c:15:12 (python+0x15a840) (BuildId: ba673fbbe716d09ffde3346e89a86287691724bc)

SUMMARY: ThreadSanitizer: data race /home/ken/Documents/GitHub/cpython/Objects/frameobject.c:1659:26 in frame_tp_clear

Fidget-Spinner changed the title gh-117657: Make frame clearing thread safe gh-117657: Make frame clearing thread-safe Jun 15, 2024
Fidget-Spinner requested a review from colesbury June 15, 2024 13:11
Fidget-Spinner added the needs backport to 3.13 bugs and security fixes label Jun 16, 2024

colesbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What is the test case that triggered the TSAN error?

Comment thread Objects/genobject.c Outdated
}

static void
gen_dealloc(PyGenObject *gen)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This doesn't seem right to me. tp_dealloc can't be called concurrently on an object.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In this case the racing part is mainly _PyFrame_ClearExceptCode and setting the generator's flags. _PyEval_FrameClearAndPop can race with this as it also clears a generator, but instead it's done by ceval.c.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't understand -- how can _PyFrame_ClearExceptCode race with gen_dealloc?

It looks like gen_dealloc is only called from the tp_dealloc handler. If an object is being destroyed, then no other thread has access to it (or there's a separate serious bug).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hmm I'm not too sure either. Let me revert this fix for now and try to hunt it down again.

Copy link
Copy Markdown
Member Author

What is the test case that triggered the TSAN error?

I first saw this getting triggered spuriously on our main test suite (I can't find the test now). But the TSAN logs I posted here are for the test case I wrote in this PR.

python-cla-bot Bot commented Apr 18, 2025
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label May 8, 2025

Copy link
Copy Markdown
Contributor

I think this is fixed on main by #131479

AA-Turner removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

5 participants


Back | FazBrowse Home | New Git URL