René's URL Explorer Experiment


Title: Use-after-free in PyObject_CallFinalizer when __del__ changes __class__ · Issue #159101 · python/cpython · GitHub

Open Graph Title: Use-after-free in PyObject_CallFinalizer when __del__ changes __class__ · Issue #159101 · python/cpython

X Title: Use-after-free in PyObject_CallFinalizer when __del__ changes __class__ · Issue #159101 · python/cpython

Description: Bug description PyObject_CallFinalizer() keeps a borrowed pointer to the object's original type across tp_finalize(self). A Python __del__ method can change self.__class__; cyclic GC can then free the original heap type before PyObject_C...

Open Graph Description: Bug description PyObject_CallFinalizer() keeps a borrowed pointer to the object's original type across tp_finalize(self). A Python __del__ method can change self.__class__; cyclic GC can then free ...

X Description: Bug description PyObject_CallFinalizer() keeps a borrowed pointer to the object's original type across tp_finalize(self). A Python __del__ method can change self.__class__; cyclic GC can then f...

Opengraph URL: https://github.com/python/cpython/issues/159101

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use-after-free in PyObject_CallFinalizer when __del__ changes __class__","articleBody":"### Bug description\n\n`PyObject_CallFinalizer()` keeps a borrowed pointer to the object's original type across `tp_finalize(self)`. A Python `__del__` method can change `self.__class__`; cyclic GC can then free the original heap type before `PyObject_CallFinalizer()` reads `tp->tp_flags` again, causing a heap use-after-free.\n\nThis reproduces on current `main` in a release-mode AddressSanitizer build. The same PoC also reproduces without the explicit `gc.collect()` call when ordinary allocations trigger collection.\n\n```python\nimport gc\n\nclass Survivor:\n    pass\n\ndef make():\n    class Temporal:\n        def __del__(self):\n            self.__class__ = Survivor\n            gc.collect()\n    return Temporal()\n\nvictim = make()\ndel victim\n```\n\nThe relevant sequence is:\n\n```c\nPyTypeObject *tp = Py_TYPE(self);\ntp->tp_finalize(self);       // __del__ changes self.__class__; GC frees tp\nif (_PyType_IS_GC(tp)) {     // reads the freed type\n    _PyGC_SET_FINALIZED(self);\n}\n```\n\nBuild and run:\n\n```console\n$ ac_cv_header_libintl_h=no ../cpython/configure \\\n    --with-address-sanitizer --without-pymalloc \\\n    CFLAGS='-O1 -g -fno-omit-frame-pointer'\n$ make -j8\n$ ASAN_OPTIONS=detect_leaks=0 ./python.exe poc.py\n```\n\n\u003cdetails>\n\u003csummary>Complete AddressSanitizer report\u003c/summary>\n\n```text\n=================================================================\n==31580==ERROR: AddressSanitizer: heap-use-after-free on address 0x61900003c138 at pc 0x000104e9e790 bp 0x00016b160b20 sp 0x00016b160b18\nREAD of size 8 at 0x61900003c138 thread T0\n==31580==WARNING: external symbolizer didn't start up correctly!\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104e9e78c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104f207d4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104eac858\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104e58f0c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105060590\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105062f44\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10505d88c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051b21d4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051ac4a0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051abb14\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1052199d0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10521847c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105218c44\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105218df4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x181ed44e0\"\n    #0 0x000104e9e78c in PyObject_CallFinalizerFromDealloc+0x230 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10020278c)\n    #1 0x000104f207d4 in subtype_dealloc+0x310 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1002847d4)\n    #2 0x000104eac858 in py_dealloc+0x230 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x100210858)\n    #3 0x000104e58f0c in _PyDict_DelItem_KnownHash_LockHeld+0x280 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1001bcf0c)\n    #4 0x000105060590 in _PyEval_StoreName+0x3c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c4590)\n    #5 0x000105062f44 in _PyEval_EvalFrameDefault+0x2764 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c6f44)\n    #6 0x00010505d88c in PyEval_EvalCode+0x370 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c188c)\n    #7 0x0001051b21d4 in run_mod+0x488 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1005161d4)\n    #8 0x0001051ac4a0 in _PyRun_SimpleFile+0x47c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1005104a0)\n    #9 0x0001051abb14 in _PyRun_AnyFile+0x98 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10050fb14)\n    #10 0x0001052199d0 in pymain_run_file+0x25c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057d9d0)\n    #11 0x00010521847c in Py_RunMain+0xb30 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057c47c)\n    #12 0x000105218c44 in pymain_main+0x2c4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057cc44)\n    #13 0x000105218df4 in Py_BytesMain+0xd4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057cdf4)\n    #14 0x000181ed44e0 in start+0x1b4c (/usr/lib/dyld:arm64e+0x204e0)\n\n0x61900003c138 is located 184 bytes inside of 1008-byte region [0x61900003c080,0x61900003c470)\nfreed by thread T0 here:\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x106359368\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104eac858\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051147f0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10521be94\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104da51ec\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10505e8ac\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10506fbfc\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10505df18\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104da569c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104f36368\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104e9e63c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104f207d4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104eac858\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104e58f0c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105060590\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105062f44\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10505d88c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051b21d4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051ac4a0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051abb14\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1052199d0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10521847c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105218c44\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105218df4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x181ed44e0\"\n    #0 0x000106359368 in free+0x7c (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/21/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:arm64e+0x41368)\n    #1 0x000104eac858 in py_dealloc+0x230 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x100210858)\n    #2 0x0001051147f0 in gc_collect_main+0x167c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1004787f0)\n    #3 0x00010521be94 in gc_collect+0x1f0 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057fe94)\n    #4 0x000104da51ec in PyObject_Vectorcall+0x88 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1001091ec)\n    #5 0x00010505e8ac in _Py_VectorCallInstrumentation_StackRefSteal+0x1c4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c28ac)\n    #6 0x00010506fbfc in _PyEval_EvalFrameDefault+0xf41c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003d3bfc)\n    #7 0x00010505df18 in _PyEval_Vector+0x3e4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c1f18)\n    #8 0x000104da569c in PyObject_CallOneArg+0x130 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10010969c)\n    #9 0x000104f36368 in slot_tp_finalize+0x12c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10029a368)\n    #10 0x000104e9e63c in PyObject_CallFinalizerFromDealloc+0xe0 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10020263c)\n    #11 0x000104f207d4 in subtype_dealloc+0x310 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1002847d4)\n    #12 0x000104eac858 in py_dealloc+0x230 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x100210858)\n    #13 0x000104e58f0c in _PyDict_DelItem_KnownHash_LockHeld+0x280 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1001bcf0c)\n    #14 0x000105060590 in _PyEval_StoreName+0x3c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c4590)\n    #15 0x000105062f44 in _PyEval_EvalFrameDefault+0x2764 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c6f44)\n    #16 0x00010505d88c in PyEval_EvalCode+0x370 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c188c)\n    #17 0x0001051b21d4 in run_mod+0x488 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1005161d4)\n    #18 0x0001051ac4a0 in _PyRun_SimpleFile+0x47c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1005104a0)\n    #19 0x0001051abb14 in _PyRun_AnyFile+0x98 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10050fb14)\n    #20 0x0001052199d0 in pymain_run_file+0x25c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057d9d0)\n    #21 0x00010521847c in Py_RunMain+0xb30 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057c47c)\n    #22 0x000105218c44 in pymain_main+0x2c4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057cc44)\n    #23 0x000105218df4 in Py_BytesMain+0xd4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057cdf4)\n    #24 0x000181ed44e0 in start+0x1b4c (/usr/lib/dyld:arm64e+0x204e0)\n\npreviously allocated by thread T0 here:\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x106359274\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104f054ac\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104f05250\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104f11044\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104f0f020\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104da3ddc\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104da39b0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105050238\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104da51ec\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10505e8ac\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10506fbfc\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10505d88c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051b21d4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051ac4a0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1051abb14\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x1052199d0\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x10521847c\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105218c44\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x105218df4\"\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x181ed44e0\"\n    #0 0x000106359274 in malloc+0x78 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/21/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:arm64e+0x41274)\n    #1 0x000104f054ac in _PyType_AllocNoTrack+0xfc (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1002694ac)\n    #2 0x000104f05250 in PyType_GenericAlloc+0x1c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x100269250)\n    #3 0x000104f11044 in type_new+0xc88 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x100275044)\n    #4 0x000104f0f020 in type_call+0x1bc (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x100273020)\n    #5 0x000104da3ddc in _PyObject_MakeTpCall+0x1a8 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x100107ddc)\n    #6 0x000104da39b0 in _PyObject_VectorcallDictTstate+0x2a4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1001079b0)\n    #7 0x000105050238 in builtin___build_class__+0xad4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003b4238)\n    #8 0x000104da51ec in PyObject_Vectorcall+0x88 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1001091ec)\n    #9 0x00010505e8ac in _Py_VectorCallInstrumentation_StackRefSteal+0x1c4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c28ac)\n    #10 0x00010506fbfc in _PyEval_EvalFrameDefault+0xf41c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003d3bfc)\n    #11 0x00010505d88c in PyEval_EvalCode+0x370 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1003c188c)\n    #12 0x0001051b21d4 in run_mod+0x488 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1005161d4)\n    #13 0x0001051ac4a0 in _PyRun_SimpleFile+0x47c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x1005104a0)\n    #14 0x0001051abb14 in _PyRun_AnyFile+0x98 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10050fb14)\n    #15 0x0001052199d0 in pymain_run_file+0x25c (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057d9d0)\n    #16 0x00010521847c in Py_RunMain+0xb30 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057c47c)\n    #17 0x000105218c44 in pymain_main+0x2c4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057cc44)\n    #18 0x000105218df4 in Py_BytesMain+0xd4 (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10057cdf4)\n    #19 0x000181ed44e0 in start+0x1b4c (/usr/lib/dyld:arm64e+0x204e0)\n\n==31580==WARNING: Can't read from symbolizer at fd 3\n==31580==WARNING: atos failed to symbolize address \"0x104e9e78c\"\nSUMMARY: AddressSanitizer: heap-use-after-free (/Users/jackfromeast/Documents/Codex/2026-10-09/c/work/cpython-c42-build/python.exe:arm64+0x10020278c) in PyObject_CallFinalizerFromDealloc+0x230\nShadow bytes around the buggy address:\n  0x61900003be80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n  0x61900003bf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa fa\n  0x61900003bf80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x61900003c000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\n  0x61900003c080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\n=>0x61900003c100: fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd fd fd\n  0x61900003c180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\n  0x61900003c200: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\n  0x61900003c280: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\n  0x61900003c300: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\n  0x61900003c380: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\nShadow byte legend (one shadow byte represents 8 application bytes):\n  Addressable:           00\n  Partially addressable: 01 02 03 04 05 06 07 \n  Heap left redzone:       fa\n  Freed heap region:       fd\n  Stack left redzone:      f1\n  Stack mid redzone:       f2\n  Stack right redzone:     f3\n  Stack after return:      f5\n  Stack use after scope:   f8\n  Global redzone:          f9\n  Global init order:       f6\n  Poisoned by user:        f7\n  Container overflow:      fc\n  Array cookie:            ac\n  Intra object redzone:    bb\n  ASan internal:           fe\n  Left alloca redzone:     ca\n  Right alloca redzone:    cb\n==31580==ABORTING\n```\n\n\u003c/details>\n\n### CPython versions tested on\n\nCurrent `main` at `0ec3aee262b03276a18aeb23cb9957e1b57c9d08`: AddressSanitizer heap-use-after-free (exit code 134).\n\n### Operating systems tested on\n\nmacOS 26.6 (arm64)\n\n### Output from running 'python -VV' on the command line\n\n```text\nPython 3.16.0a0 (heads/main-dirty:0ec3aee26, Oct 10 2026, 00:11:48) [Clang 21.0.0 (clang-2100.3.34.2)]\n```\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159888\n* gh-161534\n* gh-161535\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/yet-another-agent","@type":"Person","name":"yet-another-agent"},"datePublished":"2026-10-10T07:13:48Z","url":"https://github.com/python/cpython/issues/159101"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2e75799f-b0ad-fafd-4e84-2a35b8f24947
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9276:D1D28:160E5B0:1D40CFB:6B020257
html-safe-noncea9711bd7f29b5e46932019523b92b98368be7e89d57af970920e401fe7aa3aa1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Mjc2OkQxRDI4OjE2MEU1QjA6MUQ0MENGQjo2QjAyMDI1NyIsInZpc2l0b3JfaWQiOiI4MjA1MjE1NDQwODc2NzMzMDE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb1213fda6c511472fcdaebde5439c00e88984a15897761faf912df2ad8d77aaf
hovercard-subject-tagissue:5789085062
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/159101/issue_layout
twitter:imagehttps://opengraph.githubassets.com/15b5816a096ca93dac70d254468002e9b54f1373f7a8d96d52ebe0d5c9bfa937/python/cpython/issues/159101
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/15b5816a096ca93dac70d254468002e9b54f1373f7a8d96d52ebe0d5c9bfa937/python/cpython/issues/159101
og:image:altBug description PyObject_CallFinalizer() keeps a borrowed pointer to the object's original type across tp_finalize(self). A Python __del__ method can change self.__class__; cyclic GC can then free ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameyet-another-agent
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/159101#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159101
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159101
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/159101
Reloadhttps://github.com/python/cpython/issues/159101
Reloadhttps://github.com/python/cpython/issues/159101
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159101
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159101
Use-after-free in PyObject_CallFinalizer when __del__ changes __class__https://github.com/python/cpython/issues/159101#top
https://github.com/sergey-miryanov
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/yet-another-agent
yet-another-agenthttps://github.com/yet-another-agent
on Oct 10, 2026https://github.com/python/cpython/issues/159101#issue-5789085062
GH-159101: Fix UAF when tp_finalize changes the base class #159888https://github.com/python/cpython/pull/159888
[3.15] GH-159101: Fix UAF when tp_finalize changes the base class (GH-159888) #161534https://github.com/python/cpython/pull/161534
[3.14] GH-159101: Fix UAF when tp_finalize changes the base class (GH-159888) #161535https://github.com/python/cpython/pull/161535
https://github.com/sergey-miryanov
sergey-miryanovhttps://github.com/sergey-miryanov
on Oct 10, 2026https://github.com/python/cpython/issues/159101#issuecomment-6095206980
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Oct 10, 2026https://github.com/python/cpython/issues/159101#issuecomment-6096251177
picnixzhttps://github.com/picnixz
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Oct 10, 2026https://github.com/python/cpython/issues/159101#event-32935883492
sergey-miryanovhttps://github.com/sergey-miryanov
on Oct 17, 2026https://github.com/python/cpython/issues/159101#event-33543234045
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159101#event-33592156374
github-project-automationhttps://github.com/apps/github-project-automation
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159101
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159101#event-33592175677
sergey-miryanovhttps://github.com/sergey-miryanov
on Nov 7, 2026https://github.com/python/cpython/issues/159101#event-35417807565
GH-159101: Fix UAF when tp_finalize changes the base class (#159888)https://github.com/python/cpython/commit/6c5596c7199792ea1e8cf26f65da8cd0023c0473
GH-159101https://github.com/python/cpython/issues/159101
#159888https://github.com/python/cpython/pull/159888
6c5596chttps://github.com/python/cpython/commit/6c5596c7199792ea1e8cf26f65da8cd0023c0473
https://github.com/sergey-miryanov
sergey-miryanovhttps://github.com/sergey-miryanov
on Nov 7, 2026https://github.com/python/cpython/issues/159101#issuecomment-6703871154
@hugovkhttps://github.com/hugovk
sergey-miryanovhttps://github.com/sergey-miryanov
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
on Nov 7, 2026https://github.com/python/cpython/issues/159101#event-35422789553
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/159101
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/159101
sergey-miryanovhttps://github.com/sergey-miryanov
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
3.16new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.16%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.