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 — Not all types have "trashcan" protection and tp_dealloc can overflow stack · Issue #124715 · python/cpython

Not all types have "trashcan" protection and tp_dealloc can overflow stack #124715

New issue
Copy link
New issue
Copy link
Closed
Closed
Not all types have "trashcan" protection and tp_dealloc can overflow stack#124715
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

@nascheme
nascheme
opened on Sep 27, 2024
Issue body actions

We occasionally fix these kinds of bugs, like GH-102356. However, the fix by adding the "trashcan" macros to the tp_dealloc method only fixes that specific type. It would be better to have a more generic fix. A crash due to the C stack overflow leaves the user mystified as to what the problem is and these kinds of bugs could be hard to reproduce (requiring long chains of objects calling tp_dealloc recursively).

Linked PRs

  • GH-124715: trashcan protection for all GC objects #124716
  • GH-124715: Move trashcan mechanism into Py_Dealloc #132280
  • gh-124715: Fix method_dealloc(): use PyObject_GC_UnTrack() #133199
  • Revert "gh-124715: Fix method_dealloc(): use PyObject_GC_UnTrack() (#133199)" #133434

Activity

  1. nascheme
    added
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    on Sep 27, 2024
  2. markshannon
    added a commit that references this issue on Apr 30, 2025

    GH-124715: Move trashcan mechanism into `Py_Dealloc` (GH-132280)

    44e4c47
  3. vstinner
    added a commit that references this issue on May 1, 2025

    gh-124715: Fix method_dealloc(): use PyObject_GC_UnTrack() (#133199)

    662dd29
  4. nascheme commented on May 1, 2025

    @nascheme
    nascheme
    on May 1, 2025
    MemberAuthor
    More actions

    Regarding untracking, when I was working on my "integrate trashcan PR", I started wondering if _PyObject_GC_UNTRACK() should just be changed to check if the object is already untracked and not crash. I originally made it not safe to call twice because I wanted the tiny performance benefit (avoid the branch, I wanted GC support to have as little extra overhead as possible). However, in retrospect, I think it was a mistake. Knowing when it is safe to call _PyObject_GC_UNTRACK() in theory is possible but in practice it gets really painful. If you look at typeobject.c, it has to take great care to avoid _PyObject_GC_UNTRACK() from crashing.

    Maybe we should profile this and see if it has any performance impact at all? There has been many bugs related to this over the years.

  5. vstinner
    added 2 commits that reference this issue on May 5, 2025

    Revert "pythongh-124715: Fix method_dealloc(): use PyObject_GC_UnTrac…

    7ce29b0

    Revert "gh-124715: Fix method_dealloc(): use PyObject_GC_UnTrack() (#…

    c336f1c
  6. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on May 17, 2025
  7. Pranjal095
    added a commit that references this issue on Jul 12, 2025

    Revert "pythongh-124715: Fix method_dealloc(): use PyObject_GC_UnTrac…

    ad5f435
  8. nascheme commented on Jul 14, 2025

    @nascheme
    nascheme
    on Jul 14, 2025
    MemberAuthor
    More actions

    I believe this issue has been fixed with GH-132280.

    Reacted by Victor Stinner
  9. nascheme
    closed this as completedon Jul 14, 2025
  10. mandolaerik
    added a commit that references this issue on Jan 23, 2026

    Revert "pythonGH-124715: Move trashcan mechanism into `Py_Dealloc` (p…

    236e1bd
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

    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.