Conversation
Use free() instead of PyMem_RawFree() in pythread_wrapper() to avoid a data race if another thread calls PyMem_SetAllocator() in parallel. Co-Authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
|
@kumaraditya303: So do you agree that this change is useful or not? IMO it's worth it to fix pythread_wrapper() (avoid using PyMem_RawFree()), because the Python test suite is always run with a hidden faulthandler thread. This thread doesn't make other memory allocations. But yes, you're right that it doesn't fix the issue in the general case. @ngoldbaum added:
|
Do you plan to re-enable the no memory tests under TSAN after this? |
|
I updated my PR to reenable "no memory" tests on TSAN. So far, I failed to reproduce the issue locally (on Fedora 44 using GCC 16.2.1). We can rely on the TSAN job on GitHub Actions.
I didn't think about this when I wrote the PR, but you're right, we should/can reenable "no memory" tests on TSAN. If I understood correctly, the data race reported by TSAN (issue gh-157415) is between a test changing Python memory allocators and the "hidden" faulthandler which uses the memory allocator. With this change, the faulthandler should no longer use the Python memory allocator, and so we should be good. |
Use free() instead of PyMem_RawFree() in pythread_wrapper() to avoid a data race if another thread calls PyMem_SetAllocator() in parallel.