Skip to content
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

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

Open
colesbury opened this issue Feb 6, 2025 · 0 comments
Open

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

colesbury opened this issue Feb 6, 2025 · 0 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@colesbury
Copy link
Contributor

colesbury commented Feb 6, 2025

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);

@colesbury colesbury added topic-free-threading type-bug An unexpected behavior, bug, or error labels Feb 6, 2025
colesbury added a commit to colesbury/cpython that referenced this issue Feb 6, 2025
Skip `test_no_copies_if_tlbc_disabled` when run under TSAN for now
due to a data race on the adaptive counter (see pythongh-129752).
@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Feb 7, 2025
colesbury added a commit to colesbury/cpython that referenced this issue Feb 10, 2025
Skip `test_no_copies_if_tlbc_disabled` when run under TSAN for now
due to a data race on the adaptive counter (see pythongh-129752).
colesbury added a commit that referenced this issue Feb 11, 2025
Skip `test_no_copies_if_tlbc_disabled` when run under TSAN for now
due to a data race on the adaptive counter (see gh-129752).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants