GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — _tracemalloc__get_object_traceback doesn't handle objects with pre-headers correctly · Issue #101430 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
_tracemalloc__get_object_traceback doesn't handle objects with pre-headers correctly#101430
Copy link
Labels
3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@colesbury
colesbury
opened on Jan 30, 2023
Issue body actions

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

  • gh-101430: Update tracemalloc to handle presize properly. #101745

Activity

  1. colesbury
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.12only security fixesonly security fixes
    on Jan 30, 2023
  2. colesbury commented on Jan 30, 2023

    @colesbury
    colesbury
    on Jan 30, 2023
    ContributorAuthor
    More actions

    Also _PyTraceMalloc_NewReference:

    cpython/Modules/_tracemalloc.c

    Lines 1726 to 1733 in 28db978

    uintptr_t ptr;
    PyTypeObject *type = Py_TYPE(op);
    if (PyType_IS_GC(type)) {
    ptr = (uintptr_t)((char *)op - sizeof(PyGC_Head));
    }
    else {
    ptr = (uintptr_t)op;
    }

  3. corona10
    added 3 commits that reference this issue on Feb 9, 2023

    pythongh-101430: Update tracemalloc to handle presize properly.

    f3808bf

    pythongh-101430: Update tracemalloc to handle presize properly.

    6b451fa

    gh-101430: Update tracemalloc to handle presize properly. (gh-101745)

    5b946d3
  4. corona10
    closed this as completedon Feb 9, 2023
  5. carljm
    added a commit that references this issue on Feb 10, 2023

    Merge branch 'main' into inlinecomp2

    add772e
  6. vstinner commented on Apr 5, 2023

    @vstinner
    vstinner
    on Apr 5, 2023
    Member
    More actions

    If someone is motivated, it would be nice to add an unit test to test_tracemalloc for this case.

  7. zhuyifei1999
    added 2 commits that reference this issue on May 13, 2023

    hv_cli_prod.c: Fix producer profile for Python 3.11

    b1af54e

    hv_cli_prod.c: Fix producer profile for Python 3.11

    e80cafb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.