Skip to content

gh-132551: add missing critical sections on BytesIO methods #137073

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

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Jul 24, 2025

Follow up for #132616 and adds missing critical sections, this fixes data races on self->buf when checking for closed object:

ARNING: ThreadSanitizer: data race (pid=80476)
  Write of size 8 at 0x000118135d60 by thread T26239:
    #0 resize_buffer_lock_held bytesio.c:172 (libpython3.15t.dylib:arm64+0x3d484c)
    #1 write_bytes_lock_held bytesio.c:216 (libpython3.15t.dylib:arm64+0x3d4658)
    #2 _io_BytesIO_write bytesio.c.h:489 (libpython3.15t.dylib:arm64+0x3d1e84)
    #3 _PyEval_EvalFrameDefault generated_cases.c.h:2487 (libpython3.15t.dylib:arm64+0x277ea0)
    #4 _PyEval_Vector ceval.c:1977 (libpython3.15t.dylib:arm64+0x26a148)
    #5 _PyFunction_Vectorcall call.c (libpython3.15t.dylib:arm64+0x7fe5c)
    #6 method_vectorcall classobject.c:73 (libpython3.15t.dylib:arm64+0x8439c)
    #7 context_run context.c:728 (libpython3.15t.dylib:arm64+0x2b4bfc)
    #8 _PyEval_EvalFrameDefault generated_cases.c.h:3766 (libpython3.15t.dylib:arm64+0x27f484)
    #9 _PyEval_Vector ceval.c:1977 (libpython3.15t.dylib:arm64+0x26a148)
    #10 _PyFunction_Vectorcall call.c (libpython3.15t.dylib:arm64+0x7fe5c)
    #11 method_vectorcall classobject.c:73 (libpython3.15t.dylib:arm64+0x8439c)
    #12 _PyObject_Call call.c:348 (libpython3.15t.dylib:arm64+0x7fad4)
    #13 PyObject_Call call.c:373 (libpython3.15t.dylib:arm64+0x7fb48)
    #14 thread_run _threadmodule.c:373 (libpython3.15t.dylib:arm64+0x4174f4)
    #15 pythread_wrapper thread_pthread.h:232 (libpython3.15t.dylib:arm64+0x356b4c)

  Previous read of size 8 at 0x000118135d60 by thread T26238:
    #0 _io_BytesIO_isatty bytesio.c.h:155 (libpython3.15t.dylib:arm64+0x3d1c10)
    #1 method_vectorcall_NOARGS descrobject.c:448 (libpython3.15t.dylib:arm64+0x96e1c)
    #2 PyObject_VectorcallMethod call.c:859 (libpython3.15t.dylib:arm64+0x81550)
    #3 _io_TextIOWrapper_isatty textio.c.h:1114 (libpython3.15t.dylib:arm64+0x3e7c5c)
    #4 method_vectorcall_NOARGS descrobject.c:448 (libpython3.15t.dylib:arm64+0x96e1c)
    #5 PyObject_Vectorcall call.c:327 (libpython3.15t.dylib:arm64+0x7f824)
    #6 _PyEval_EvalFrameDefault generated_cases.c.h:1620 (libpython3.15t.dylib:arm64+0x276f24)
    #7 _PyEval_Vector ceval.c:1977 (libpython3.15t.dylib:arm64+0x26a148)
    #8 _PyFunction_Vectorcall call.c (libpython3.15t.dylib:arm64+0x7fe5c)
    #9 method_vectorcall classobject.c:73 (libpython3.15t.dylib:arm64+0x8439c)
    #10 context_run context.c:728 (libpython3.15t.dylib:arm64+0x2b4bfc)
    #11 _PyEval_EvalFrameDefault generated_cases.c.h:3766 (libpython3.15t.dylib:arm64+0x27f484)
    #12 _PyEval_Vector ceval.c:1977 (libpython3.15t.dylib:arm64+0x26a148)
    #13 _PyFunction_Vectorcall call.c (libpython3.15t.dylib:arm64+0x7fe5c)
    #14 method_vectorcall classobject.c:73 (libpython3.15t.dylib:arm64+0x8439c)
    #15 _PyObject_Call call.c:348 (libpython3.15t.dylib:arm64+0x7fad4)
    #16 PyObject_Call call.c:373 (libpython3.15t.dylib:arm64+0x7fb48)
    #17 thread_run _threadmodule.c:373 (libpython3.15t.dylib:arm64+0x4174f4)
    #18 pythread_wrapper thread_pthread.h:232 (libpython3.15t.dylib:arm64+0x356b4c)

@kumaraditya303 kumaraditya303 enabled auto-merge (squash) July 24, 2025 11:50
@kumaraditya303 kumaraditya303 merged commit d8fa40b into python:main Jul 24, 2025
60 of 79 checks passed
@miss-islington-app
Copy link

Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @kumaraditya303, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker d8fa40b08da60a711311751891fa830cb4ae77f3 3.14

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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy