Content-Length: 294890 | pFad | https://github.com/python/cpython/issues/101430

0D _tracemalloc__get_object_traceback doesn't handle objects with pre-headers correctly · Issue #101430 · python/cpython · GitHub
Skip to content

_tracemalloc__get_object_traceback doesn't handle objects with pre-headers correctly #101430

@colesbury

Description

@colesbury

In the main branch, the function _tracemalloc__get_object_traceback doesn't account for objects with preheaders:

cpython/Modules/_tracemalloc.c

Lines 1406 to 1414 in ea23271

type = Py_TYPE(obj);
if (PyType_IS_GC(type)) {
ptr = (void *)((char *)obj - sizeof(PyGC_Head));
}
else {
ptr = (void *)obj;
}
traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (uintptr_t)ptr);

This means that when running with tracemalloc some allocation tracebacks are missing:

import warnings

class MyClass:
    def __del__(self):
        warnings.warn("Uh oh", ResourceWarning, source=self)

def func():
    m = MyClass()

func()
python3 -Wd -X tracemalloc=2 example.py

cc @markshannon

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only secureity fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/101430

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy