https://github.com/python/cpython/commit/44ba11a2045a8d00b6089fedd8b57f02c8a7225a
commit: 44ba11a2045a8d00b6089fedd8b57f02c8a7225a
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: Yhg1s <[email protected]>
date: 2024-09-30T13:51:24-07:00
summary:

[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 077e7ef6a0abbf9e04b9aa11b4f621031004c31f)

Co-authored-by: Dino Viehland <[email protected]>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2024-09-27-17-18-53.gh-issue-124642.OCjhBJ.rst
M Objects/dictobject.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2024-09-27-17-18-53.gh-issue-124642.OCjhBJ.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-27-17-18-53.gh-issue-124642.OCjhBJ.rst
new file mode 100644
index 00000000000000..29763844a9f592
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2024-09-27-17-18-53.gh-issue-124642.OCjhBJ.rst
@@ -0,0 +1 @@
+Fixed scalability issue in free-threaded builds for lock-free reads from 
dictionaries in multi-threaded scenarios
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 7f7fd836c01509..a5a5bce3965555 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1549,7 +1549,7 @@ _Py_dict_lookup_threadsafe(PyDictObject *mp, PyObject 
*key, Py_hash_t hash, PyOb
     *value_addr = value;
     if (value != NULL) {
         assert(ix >= 0);
-        Py_INCREF(value);
+        _Py_NewRefWithLock(value);
     }
     Py_END_CRITICAL_SECTION();
     return ix;
@@ -6988,7 +6988,7 @@ _PyObject_TryGetInstanceAttribute(PyObject *obj, PyObject 
*name, PyObject **attr
             // Still no dict, we can read from the values
             assert(values->valid);
             value = values->values[ix];
-            *attr = Py_XNewRef(value);
+            *attr = _Py_XNewRefWithLock(value);
             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)) {
         value = _Py_atomic_load_ptr_relaxed(&values->values[ix]);
-        *attr = Py_XNewRef(value);
+        *attr = _Py_XNewRefWithLock(value);
         success = true;
     } else {
         // Caller needs to lookup from the dictionary

_______________________________________________
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]

Reply via email to