cpython/Objects
Sam Gross f963239ff1
gh-130202: Fix bug in _PyObject_ResurrectEnd in free threaded build (gh-130281)
This fixes a fairly subtle bug involving finalizers and resurrection in
debug free threaded builds: if `_PyObject_ResurrectEnd` returns `1`
(i.e., the object was resurrected by a finalizer), it's not safe to
access the object because it might still be deallocated. For example:

 * The finalizer may have exposed the object to another thread. That
   thread may hold the last reference and concurrently deallocate it any
   time after `_PyObject_ResurrectEnd()` returns `1`.
 * `_PyObject_ResurrectEnd()` may call `_Py_brc_queue_object()`, which
   may internally deallocate the object immediately if the owning thread
   is dead.

Therefore, it's important not to access the object after it's
resurrected. We only violate this in two cases, and only in debug
builds:

 * We assert that the object is tracked appropriately. This is now moved
   up betewen the finalizer and the `_PyObject_ResurrectEnd()` call.

 * The `--with-trace-refs` builds may need to remember the object if
   it's resurrected. This is now handled by `_PyObject_ResurrectStart()`
   and `_PyObject_ResurrectEnd()`.

Note that `--with-trace-refs` is currently disabled in `--disable-gil`
builds because the refchain hash table isn't thread-safe, but this
refactoring avoids an additional thread-safety issue.
2025-02-25 12:03:28 -05:00
..
clinic gh-129107: make bytearray thread safe (#129108) 2025-02-15 07:19:42 +00:00
mimalloc gh-123826: Fix unused function warnings in mimalloc on NetBSD (#123827) 2024-09-09 13:22:28 -04:00
stringlib gh-87790: support thousands separators for formatting fractional part of floats (#125304) 2025-02-25 16:27:07 +01:00
abstract.c gh-128911: Add PyImport_ImportModuleAttr() function (#128912) 2025-01-30 11:17:29 +00:00
boolobject.c gh-122982: Extend the deprecation period for bool inversion by two years (#123306) 2024-08-25 12:24:44 -07:00
bytearrayobject.c gh-129107: make bytearray iterator thread safe (#130096) 2025-02-19 15:42:45 +05:30
bytes_methods.c gh-121165: protect macro expansion of ADJUST_INDICES with do-while(0) (#121166) 2024-07-02 16:27:51 +05:30
bytesobject.c gh-128016: Improved invalid escape sequence warning message (#128020) 2025-01-15 18:00:54 +01:00
call.c gh-106320: Remove _PyFunction_Vectorcall() API (#107071) 2023-07-22 21:44:33 +00:00
capsule.c gh-111178: fix UBSan failures in Objects/capsule.c (GH-128239) 2025-01-08 14:55:04 +01:00
cellobject.c gh-127271: Replace use of PyCell_GET/SET (gh-127272) 2024-12-03 10:33:06 -08:00
classobject.c gh-126703: Add freelist for PyMethodObject (#128594) 2025-01-12 18:31:49 +05:30
codeobject.c GH-128872: Remove unused argument from _PyCode_Quicken (GH-128873) 2025-02-02 15:09:30 -08:00
complexobject.c gh-111178: fix UBSan failures in Objects/complexobject.c (GH-128241) 2025-01-10 10:46:36 +00:00
descrobject.c gh-128863: Deprecate private C API functions (#128864) 2025-01-22 11:04:19 +00:00
dictnotes.txt bpo-46845: Reduce dict size when all keys are Unicode (GH-31564) 2022-03-02 08:09:28 +09:00
dictobject.c gh-130313: Avoid locking when clearing objects (#130126) 2025-02-20 13:32:57 -08:00
enumobject.c gh-111178: fix UBSan failures in Objects/enumobject.c (GH-128246) 2025-01-03 15:29:41 +01:00
exceptions.c gh-111178: fix UBSan failures in Objects/exceptions.c (GH-128154) 2025-02-17 11:03:16 +01:00
fileobject.c gh-128911: Add PyImport_ImportModuleAttr() function (#128912) 2025-01-30 11:17:29 +00:00
floatobject.c gh-111178: fix UBSan failures in Objects/floatobject.c (GH-129776) 2025-02-08 14:47:19 +01:00
frameobject.c gh-128396: Fix a crash when inline comprehension has the same local variable as the outside scope (#130235) 2025-02-19 12:11:17 -05:00
funcobject.c gh-128714: Fix function object races in __annotate__, __annotations__ and __type_params__ in free-threading build (#129016) 2025-02-06 20:10:50 +05:30
genericaliasobject.c gh-119180: Add evaluate functions for type params and type aliases (#122212) 2024-07-27 17:24:10 +00:00
genobject.c gh-129354: Use PyErr_FormatUnraisable() function (#129523) 2025-02-05 10:31:59 +00:00
iterobject.c gh-128078: Clear exception in anext before calling _PyGen_SetStopIterationValue (#128780) 2025-01-13 18:25:09 +05:30
listobject.c gh-115999: Make list and tuple iteration more thread-safe. (#128637) 2025-02-18 16:52:46 -08:00
listsort.txt GH-116939: Rewrite binarysort() (#116940) 2024-03-21 22:27:25 -05:00
lnotab_notes.txt gh-119786: add code object doc, inline locations.md into it (#126832) 2024-11-22 19:27:41 +00:00
longobject.c gh-127119: Faster check for small ints in long_dealloc (GH-127620) 2025-01-29 15:22:18 +00:00
memoryobject.c gh-128911: Add PyImport_ImportModuleAttr() function (#128912) 2025-01-30 11:17:29 +00:00
methodobject.c gh-128863: Deprecate private C API functions (#128864) 2025-01-22 11:04:19 +00:00
moduleobject.c gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475) 2025-01-31 09:45:35 +01:00
namespaceobject.c gh-128198: Add missing error checks for usages of PyIter_Next() (GH-128199) 2024-12-25 19:42:04 +02:00
object.c gh-130202: Fix bug in _PyObject_ResurrectEnd in free threaded build (gh-130281) 2025-02-25 12:03:28 -05:00
object_layout.md GH-115776: Allow any fixed sized object to have inline values (GH-123192) 2024-08-21 15:52:04 +01:00
object_layout_312.gv GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_312.png GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_313.gv GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_313.png GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_full_312.gv GH-96068: Document object layout (GH-96069) 2022-08-23 13:55:43 +01:00
object_layout_full_312.png GH-96068: Document object layout (GH-96069) 2022-08-23 13:55:43 +01:00
object_layout_full_313.gv GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
object_layout_full_313.png GH-115776: Embed the values array into the object, for "normal" Python objects. (GH-116115) 2024-04-02 11:59:21 +01:00
obmalloc.c gh-111924: Fix data races when swapping allocators (gh-130287) 2025-02-20 11:31:15 -05:00
odictobject.c gh-128863: Deprecate private C API functions (#128864) 2025-01-22 11:04:19 +00:00
picklebufobject.c gh-104922: remove PY_SSIZE_T_CLEAN (#106315) 2023-07-02 15:07:46 +09:00
rangeobject.c gh-111178: fix some USAN failures - mismatched function pointers (GH-123004) 2024-09-27 23:51:50 +02:00
README
setobject.c gh-129967: Fix race condition in repr(set) (gh-129978) 2025-02-11 17:29:27 -05:00
sliceobject.c gh-128863: Deprecate _PyLong_Sign() function (#129176) 2025-01-23 03:11:53 +01:00
structseq.c GH-125174: Make immortal objects more robust, following design from PEP 683 (GH-125251) 2024-10-10 18:19:08 +01:00
tupleobject.c gh-115999: Make list and tuple iteration more thread-safe. (#128637) 2025-02-18 16:52:46 -08:00
typeobject.c gh-111178: fix UBSan failures in Objects/typeobject.c (#129799) 2025-02-25 10:44:59 +00:00
typeslots.inc gh-124153: Implement PyType_GetBaseByToken() and Py_tp_token slot (GH-124163) 2024-09-18 09:18:19 +02:00
typeslots.py gh-124153: Implement PyType_GetBaseByToken() and Py_tp_token slot (GH-124163) 2024-09-18 09:18:19 +02:00
typevarobject.c gh-111178: fix UBSan failures in Objects/typevarobject.c (GH-129800) 2025-02-25 13:12:47 +01:00
unicodectype.c gh-82045: Correct and deduplicate "isprintable" docs; add test. (GH-130118) 2025-02-14 18:16:47 +01:00
unicodeobject.c gh-87790: support thousands separators for formatting fractional part of floats (#125304) 2025-02-25 16:27:07 +01:00
unicodetype_db.h closes gh-124016: update Unicode to 16.0.0 (#124017) 2024-09-13 07:47:04 -07:00
unionobject.c gh-119180: Add evaluate functions for type params and type aliases (#122212) 2024-07-27 17:24:10 +00:00
weakrefobject.c gh-129354: Use PyErr_FormatUnraisable() function (#129511) 2025-01-31 13:16:08 +01:00

Source files for various builtin objects