HomeAleph Objects Inc

bpo-9263: Dump Python object on GC assertion failure (GH-10062)

Authored by Victor Stinner <vstinner@redhat.com> on Oct 25 2018, 9:31 AM.

Description

bpo-9263: Dump Python object on GC assertion failure (GH-10062)

Changes:

  • Add _PyObject_AssertFailed() function.
  • Add _PyObject_ASSERT() and _PyObject_ASSERT_WITH_MSG() macros.
  • gc_decref(): replace assert() with _PyObject_ASSERT_WITH_MSG() to dump the faulty object if the assertion fails.

_PyObject_AssertFailed() calls:

  • _PyMem_DumpTraceback(): try to log the traceback where the object memory has been allocated if tracemalloc is enabled.
  • _PyObject_Dump(): log repr(obj).
  • Py_FatalError(): log the current Python traceback.

_PyObject_AssertFailed() uses _PyObject_IsFreed() heuristic to check
if the object memory has been freed by a debug hook on Python memory
allocators.

Initial patch written by David Malcolm.

Co-Authored-By: David Malcolm <dmalcolm@redhat.com>

Details

Committed
GitHub <noreply@github.com>Oct 25 2018, 9:31 AM
Parents
rCP18618e652c56: bpo-35059: Add Py_STATIC_INLINE() macro (GH-10093)
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rCP626bff856840: bpo-9263: Dump Python object on GC assertion failure (GH-10062) (authored by Victor Stinner <vstinner@redhat.com>).Oct 25 2018, 9:31 AM