8000 gh-128212: Fix race in `_PyUnicode_CheckConsistency` (GH-128367) · python/cpython@8eebe4e · GitHub
[go: up one dir, main page]

Skip to content

Commit 8eebe4e

Browse files
authored
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.
1 parent c9356fe commit 8eebe4e
8000

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
688688
|| kind == PyUnicode_2BYTE_KIND
689689
|| kind == PyUnicode_4BYTE_KIND);
690690
CHECK(ascii->state.ascii == 0);
691-
CHECK(compact->utf8 != data);
691+
CHECK(_PyUnicode_UTF8(op) != data);
692692
}
693693
else {
694694
PyUnicodeObject *unicode = _PyUnicodeObject_CAST(op);

0 commit comments

Comments
 (0)
0