Skip to content

Data race on adaptive counters with -X tlbc=0 in free threaded build #129752

Open
@colesbury

Description

@colesbury

Bug report

TSan reports data races for test_thread_local_bytecode.test_no_copies_if_tlbc_disabled.

WARNING: ThreadSanitizer: data race (pid=1222408)
  Read of size 2 at 0x7fffb44d7cc2 by thread T2:
    #0 _PyEval_EvalFrameDefault /raid/sgross/cpython/Python/generated_cases.c.h:7283:36 (python+0x402a47) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #1 _PyEval_EvalFrame /raid/sgross/cpython/./Include/internal/pycore_ceval.h:116:16 (python+0x3f48ea) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #2 _PyEval_Vector /raid/sgross/cpython/Python/ceval.c:1761:12 (python+0x3f48ea)
    #3 _PyFunction_Vectorcall /raid/sgross/cpython/Objects/call.c (python+0x1ef79f) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #4 _PyObject_VectorcallTstate /raid/sgross/cpython/./Include/internal/pycore_call.h:167:11 (python+0x1f3f9f) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #5 method_vectorcall /raid/sgross/cpython/Objects/classobject.c:72:20 (python+0x1f3f9f)
    #6 _PyVectorcall_Call /raid/sgross/cpython/Objects/call.c:273:16 (python+0x1ef413) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #7 _PyObject_Call /raid/sgross/cpython/Objects/call.c:348:16 (python+0x1ef413)
    #8 PyObject_Call /raid/sgross/cpython/Objects/call.c:373:12 (python+0x1ef495) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #9 thread_run /raid/sgross/cpython/./Modules/_threadmodule.c:354:21 (python+0x58d1d2) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #10 pythread_wrapper /raid/sgross/cpython/Python/thread_pthread.h:242:5 (python+0x4e89c7) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)

  Previous write of size 2 at 0x7fffb44d7cc2 by main thread:
    #0 _PyEval_EvalFrameDefault /raid/sgross/cpython/Python/generated_cases.c.h:7295:17 (python+0x402af4) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #1 _PyEval_EvalFrame /raid/sgross/cpython/./Include/internal/pycore_ceval.h:116:16 (python+0x3f48ea) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #2 _PyEval_Vector /raid/sgross/cpython/Python/ceval.c:1761:12 (python+0x3f48ea)
    #3 PyEval_EvalCode /raid/sgross/cpython/Python/ceval.c:662:21 (python+0x3f43fd) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #4 run_eval_code_obj /raid/sgross/cpython/Python/pythonrun.c:1331:9 (python+0x4c6e2e) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #5 run_mod /raid/sgross/cpython/Python/pythonrun.c:1406:19 (python+0x4c6b5f) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #6 _PyRun_StringFlagsWithName /raid/sgross/cpython/Python/pythonrun.c:1215:15 (python+0x4c3a75) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #7 _PyRun_SimpleStringFlagsWithName /raid/sgross/cpython/Python/pythonrun.c:548:15 (python+0x4c3a75)
    #8 pymain_run_command /raid/sgross/cpython/Modules/main.c:253:11 (python+0x502c21) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #9 pymain_run_python /raid/sgross/cpython/Modules/main.c:678:21 (python+0x502c21)
    #10 Py_RunMain /raid/sgross/cpython/Modules/main.c:766:5 (python+0x502c21)
    #11 pymain_main /raid/sgross/cpython/Modules/main.c:796:12 (python+0x5031b8) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #12 Py_BytesMain /raid/sgross/cpython/Modules/main.c:820:12 (python+0x50323b) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)
    #13 main /raid/sgross/cpython/./Programs/python.c:15:12 (python+0x16417b) (BuildId: d2c9a0e659ee21e3ff5331c41d7aa75d7fd2bc90)

The races are on the adaptive counter:

uint16_t counter = read_u16(&this_instr[1].cache);

ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions