Description
Bug report
Bug description:
I'm reviewing the https://github.com/python/cpython/blob/main/Modules/_ctypes/callproc.c. I believe I found a possible UB if resize
and byref
/addressof
are used from different threads without any locking (AFAIU it is valid for free-threaded build and not for GIL-enabled).
resize
does realloc
-
cpython/Modules/_ctypes/callproc.c
Lines 1934 to 1938 in d07e9eb
After realloc
the old value of obj->b_ptr
is no longer valid, and any access to it is UB. If another thread calls addressof
cpython/Modules/_ctypes/callproc.c
Line 1847 in d07e9eb
byref
cpython/Modules/_ctypes/callproc.c
Line 1827 in d07e9eb
Should we protect them with LOCK_PTR
?
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response