mirror of
https://github.com/python/cpython.git
synced 2025-09-04 16:01:10 +00:00
[3.13] gh-124642: Dictionaries aren't marking objects as weakref'd (GH-124643) (#124798)
gh-124642: Dictionaries aren't marking objects as weakref'd (GH-124643)
Dictionaries aren't marking objects as weakref'd
(cherry picked from commit 077e7ef6a0
)
Co-authored-by: Dino Viehland <dinoviehland@meta.com>
This commit is contained in:
parent
fe58596cce
commit
44ba11a204
2 changed files with 4 additions and 3 deletions
|
@ -0,0 +1 @@
|
||||||
|
Fixed scalability issue in free-threaded builds for lock-free reads from dictionaries in multi-threaded scenarios
|
|
@ -1549,7 +1549,7 @@ read_failed:
|
||||||
*value_addr = value;
|
*value_addr = value;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
assert(ix >= 0);
|
assert(ix >= 0);
|
||||||
Py_INCREF(value);
|
_Py_NewRefWithLock(value);
|
||||||
}
|
}
|
||||||
Py_END_CRITICAL_SECTION();
|
Py_END_CRITICAL_SECTION();
|
||||||
return ix;
|
return ix;
|
||||||
|
@ -6988,7 +6988,7 @@ _PyObject_TryGetInstanceAttribute(PyObject *obj, PyObject *name, PyObject **attr
|
||||||
// Still no dict, we can read from the values
|
// Still no dict, we can read from the values
|
||||||
assert(values->valid);
|
assert(values->valid);
|
||||||
value = values->values[ix];
|
value = values->values[ix];
|
||||||
*attr = Py_XNewRef(value);
|
*attr = _Py_XNewRefWithLock(value);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7008,7 +7008,7 @@ _PyObject_TryGetInstanceAttribute(PyObject *obj, PyObject *name, PyObject **attr
|
||||||
|
|
||||||
if (dict->ma_values == values && FT_ATOMIC_LOAD_UINT8(values->valid)) {
|
if (dict->ma_values == values && FT_ATOMIC_LOAD_UINT8(values->valid)) {
|
||||||
value = _Py_atomic_load_ptr_relaxed(&values->values[ix]);
|
value = _Py_atomic_load_ptr_relaxed(&values->values[ix]);
|
||||||
*attr = Py_XNewRef(value);
|
*attr = _Py_XNewRefWithLock(value);
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
// Caller needs to lookup from the dictionary
|
// Caller needs to lookup from the dictionary
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue