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

TSAN race in _waiting_release #123828

Open
ccotter opened this issue Sep 8, 2024 · 2 comments · May be fixed by #124107
Open

TSAN race in _waiting_release #123828

ccotter opened this issue Sep 8, 2024 · 2 comments · May be fixed by #124107
Labels
extension-modules C modules in the Modules dir topic-subinterpreters type-bug An unexpected behavior, bug, or error

Comments

@ccotter
Copy link

ccotter commented Sep 8, 2024

Bug report

Bug description:

A TSAN (gcc-12) build of the latest version of cpython reports a race in the test_send_recv_different_interpreters_and_threads test:

  Read of size 4 at 0x7ffe8d0c9338 by main thread:
    #0 _waiting_finish_releasing Modules/_interpchannelsmodule.c:504 (_interpchannels.cpython-314-x86_64-linux-gnu.so+0x88f4) (BuildId: 233ea3cec8e2d6b4a5322cdab2aa3fcc24ab85f8)
    #1 channel_send_wait Modules/_interpchannelsmodule.c:1852 (_interpchannels.cpython-314-x86_64-linux-gnu.so+0x88f4)
    #2 channelsmod_send Modules/_interpchannelsmodule.c:3096 (_interpchannels.cpython-314-x86_64-linux-gnu.so+0x8dd0) (BuildId: 233ea3cec8e2d6b4a5322cdab2aa3fcc24ab85f8)
    #3 cfunction_call Objects/methodobject.c:540 (python+0x549e55) (BuildId: f667f6a4a823ca3db627f9e7bf3836f7af978c6d)

    #0 _waiting_release Modules/_interpchannelsmodule.c:498 (_interpchannels.cpython-314-x86_64-linux-gnu.so+0x37c7) (BuildId: 233ea3cec8e2d6b4a5322cdab2aa3fcc24ab85f8)
    #1 channel_recv Modules/_interpchannelsmodule.c:1937 (_interpchannels.cpython-314-x86_64-linux-gnu.so+0x863a) (BuildId: 233ea3cec8e2d6b4a5322cdab2aa3fcc24ab85f8)
    #2 channelsmod_recv Modules/_interpchannelsmodule.c:3189 (_interpchannels.cpython-314-x86_64-linux-gnu.so+0x863a)

Indeed,

while (waiting->status == WAITING_RELEASING) {
spin waits for waiting->status to change state, with
waiting->status = WAITING_RELEASED;
triggering the spinning thread to exit the spin. Neither happens under a mutex, or with any release-acquire sequencing.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@ccotter ccotter added the type-bug An unexpected behavior, bug, or error label Sep 8, 2024
@ZeroIntensity
Copy link
Member

cc @ericsnowcurrently

@n-bes
Copy link

n-bes commented Sep 11, 2024

Can confirm, reproduced on Python-3.13.0b4

p.s. summary table

If I remember correctly, this OOM related with this issue

Снимок экрана 2024-08-13 в 11 20 37

Zheaoli added a commit to Zheaoli/cpython that referenced this issue Sep 15, 2024
…erpchannelsmodule.c

Signed-off-by: Manjusaka <me@manjusaka.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir topic-subinterpreters type-bug An unexpected behavior, bug, or error
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

4 participants