mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-117657: Fix data race in new_reference
for free threaded build (gh-129665)
This commit is contained in:
parent
0d68b14a0d
commit
365cf5fc23
2 changed files with 8 additions and 2 deletions
|
@ -2485,13 +2485,20 @@ new_reference(PyObject *op)
|
|||
op->ob_refcnt = 1;
|
||||
#endif
|
||||
#else
|
||||
op->ob_tid = _Py_ThreadId();
|
||||
op->ob_flags = 0;
|
||||
op->ob_mutex = (PyMutex){ 0 };
|
||||
#ifdef _Py_THREAD_SANITIZER
|
||||
_Py_atomic_store_uintptr_relaxed(&op->ob_tid, _Py_ThreadId());
|
||||
_Py_atomic_store_uint8_relaxed(&op->ob_gc_bits, 0);
|
||||
_Py_atomic_store_uint32_relaxed(&op->ob_ref_local, 1);
|
||||
_Py_atomic_store_ssize_relaxed(&op->ob_ref_shared, 0);
|
||||
#else
|
||||
op->ob_tid = _Py_ThreadId();
|
||||
op->ob_gc_bits = 0;
|
||||
op->ob_ref_local = 1;
|
||||
op->ob_ref_shared = 0;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef Py_TRACE_REFS
|
||||
_Py_AddToAllObjects(op);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue