https://github.com/python/cpython/commit/8eebe4e6d02bb4ad3f1ca6c52624186903dce893
commit: 8eebe4e6d02bb4ad3f1ca6c52624186903dce893
branch: main
author: Sam Gross <[email protected]>
committer: colesbury <[email protected]>
date: 2025-01-02T14:02:54-05:00
summary:
gh-128212: Fix race in `_PyUnicode_CheckConsistency` (GH-128367)
There was a data race on the utf8 field between `PyUnicode_SET_UTF8` and
`_PyUnicode_CheckConsistency`. Use the `_PyUnicode_UTF8()` accessor,
which uses an atomic load internally, to avoid the data race.
files:
M Objects/unicodeobject.c
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 1aab9cf37768a8..9f0a4d4785eda6 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -688,7 +688,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
|| kind == PyUnicode_2BYTE_KIND
|| kind == PyUnicode_4BYTE_KIND);
CHECK(ascii->state.ascii == 0);
- CHECK(compact->utf8 != data);
+ CHECK(_PyUnicode_UTF8(op) != data);
}
else {
PyUnicodeObject *unicode = _PyUnicodeObject_CAST(op);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]