10000 gh-117657: TSAN Fix races in `PyMember_Get` and `PyMember_Set`, for C extensions by dpdani · Pull Request #123211 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-117657: TSAN Fix races in PyMember_Get and PyMember_Set, for C extensions #123211

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 32 commits into from
Dec 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d63eccb
gh-117657: TSAN Fix races in `PyMember_Get` and `PyMember_Set`, for C…
dpdani Aug 21, 2024
c2d3d41
exercise race in T_CHAR as well
dpdani Aug 21, 2024
f6ba4a3
signed char races
dpdani Aug 22, 2024
d9614b7
unsigned char race
dpdani Aug 22, 2024
1659849
unsigned char race 👀
dpdani Aug 22, 2024
4cfa619
unsigned char race 👀
dpdani Aug 22, 2024
107a9f5
signed short race
dpdani Aug 22, 2024
e20b9d1
unsigned short race
dpdani Aug 22, 2024
86a0945
signed int race
dpdani Aug 22, 2024
1a07031
who uses MSC anyways?
dpdani Aug 22, 2024
16f61d8
unsigned int races
dpdani Aug 22, 2024
cf25726
👀
dpdani Aug 22, 2024
d41132c
signed long race
dpdani Aug 22, 2024
2212605
unsigned long race
dpdani Aug 22, 2024
74616d6
ssizet race
dpdani Aug 22, 2024
23d10c6
float race
dpdani Aug 22, 2024
ae37a8e
double race
dpdani Aug 22, 2024
bce02d0
T_CHAR
dpdani Aug 22, 2024
afe2504
signed long long race
dpdani Aug 22, 2024
3dfaab8
unsigned long long race
dpdani Aug 22, 2024
50a7bb6
fix return type
dpdani Aug 22, 2024
416e0bb
arm64 does not have 128-bit integers, I suppose
dpdani Aug 22, 2024
4bd6927
at this point I'm just making guesses
dpdani Aug 22, 2024
a4c094b
scope
dpdani Aug 29, 2024
267f995
must 0-initialize
dpdani Aug 29, 2024
c006e1d
FT_ATOMIC_STORE_CHAR_RELEASE -> FT_ATOMIC_STORE_CHAR_RELAXED
dpdani Aug 29, 2024
488dea5
remaining release -> relaxed
dpdani Aug 29, 2024
b3b07d5
default build
dpdani Aug 29, 2024
761257e
Apply suggestions from code review
dpdani Sep 22, 2024
d045747
missing load
dpdani Sep 22, 2024
c1b4c35
fixes
dpdani Nov 2, 2024
6c5cec5
Merge branch 'main' into gh-117657-tsan-pymember-c-ext
colesbury Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
T_CHAR
  • Loading branch information
dpdani committed Aug 22, 2024
commit bce02d0d02b28a533c8cef18a72bf41c5e50669b
7 changes: 5 additions & 2 deletions Python/structmember.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ PyObject *
PyMember_GetOne(const char *obj_addr, PyMemberDef *l)
{
PyObject *v;
char value;
if (l->flags & Py_RELATIVE_OFFSET) {
PyErr_SetString(
PyExc_SystemError,
Expand Down Expand Up @@ -80,7 +81,9 @@ PyMember_GetOne(const char *obj_addr, PyMemberDef *l)
v = PyUnicode_FromString((char*)addr);
break;
case Py_T_CHAR:
v = PyUnicode_FromStringAndSize((char*)addr, 1);
// case ...: char value = ... requires a C23-compatible compiler
value = FT_ATOMIC_LOAD_CHAR_RELAXED(*(char *) addr);
v = PyUnicode_FromStringAndSize(&value, 1);
break;
case _Py_T_OBJECT:
v = *(PyObject **)addr;
Expand Down Expand Up @@ -318,7 +321,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
PyErr_BadArgument();
return -1;
}
*(char*)addr = string[0];
FT_ATOMIC_STORE_CHAR_RELEASE(*(char*)addr, string[0]);
break;
}
case Py_T_STRING:
Expand Down
0