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 — redundant decref on the eval stack value in LOAD_FROM_DICT_OR_DEREF in error path · Issue #111654 · python/cpython

redundant decref on the eval stack value in LOAD_FROM_DICT_OR_DEREF in error path #111654

New issue
Copy link
New issue
Copy link
Closed
Closed
redundant decref on the eval stack value in LOAD_FROM_DICT_OR_DEREF in error path#111654
Copy link
Assignees
JelleZijlstra
Labels
type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

@aisk
aisk
opened on Nov 2, 2023
Issue body actions

Crash report

What happened?

With these codes bellow, a NameError will be raised as expected, but there will be a runtime crash when GC happens.

def xxx():
    class MyComplex:
        MyComplex

xxx()

Error logs:

Traceback (most recent call last):
  File "C:\Users\xxxxx\Source\cpython\a.py", line 71, in <module>
    xxx()
  File "C:\Users\xxxxx\Source\cpython\a.py", line 66, in xxx
    class MyComplex:
  File "C:\Users\xxxxx\Source\cpython\a.py", line 67, in MyComplex
    MyComplex
NameError: cannot access free variable 'MyComplex' where it is not associated with a value in enclosing scope. Did you mean: 'complex'?
C:\Users\xxxxx\Source\cpython\Objects\frameobject.c:889: _Py_NegativeRefcount: Assertion failed: object has negative ref count
<object at 00000150D0CDA990 is freed>
Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: finalizing (tstate=0x00007ffc567001f8)

Current thread 0x00003564 (most recent call first):
  <no Python frame>

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

No response

Output from running 'python -VV' on the command line:

No response

Linked PRs

  • gh-111654: remove redundant decref on the eval stack value #111655
  • [3.12] gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (GH-111655) #111674

Activity

  1. aisk
    added
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    on Nov 2, 2023
  2. JelleZijlstra
    self-assigned this
    on Nov 2, 2023
  3. JelleZijlstra commented on Nov 2, 2023

    @JelleZijlstra
    JelleZijlstra
    on Nov 2, 2023
    Member
    More actions

    Similar to #109118 and #109123. I'll take a look later today.

  4. aisk commented on Nov 2, 2023

    @aisk
    aisk
    on Nov 2, 2023
    MemberAuthor
    More actions

    @JelleZijlstra Yes, I tried to figure it out from your PR #109123 as reference , I think it's the same issue in another OP code.

  5. terryjreedy commented on Nov 2, 2023

    @terryjreedy
    terryjreedy
    on Nov 2, 2023
    Member
    More actions

    I get the same crash in freshly compiled 'main', plus a few pages of garbage before 'Fatal Python error'. With released 3.13.0a1, the traceback but no crash.

  6. JelleZijlstra
    added 2 commits that reference this issue on Nov 3, 2023

    gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (#111655)

    3a1b09e

    [3.12] pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_…

    ca1da24
  7. FullteaR
    added a commit that references this issue on Nov 3, 2023

    pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (p…

    73584a0
  8. aisk commented on Nov 3, 2023

    @aisk
    aisk
    on Nov 3, 2023
    MemberAuthor
    More actions

    @terryjreedy I get the same crash on v3.13.0a1, maybe there are some compile cache mechanisms?

  9. JelleZijlstra commented on Nov 3, 2023

    @JelleZijlstra
    JelleZijlstra
    on Nov 3, 2023
    Member
    More actions

    Errors due to use-after-free can be highly dependent on, well, lots of things, because memory may either get reused immediately or kept around, and you don't know what other objects get put in the same place later. It's not surprising that the same underlying bug that causes a use-after-free can manifest in wildly different ways.

  10. JelleZijlstra
    added a commit that references this issue on Nov 3, 2023

    [3.12] gh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (G…

    1a95ad6
  11. JelleZijlstra commented on Nov 3, 2023

    @JelleZijlstra
    JelleZijlstra
    on Nov 3, 2023
    Member
    More actions

    Thanks for the report and fix!

  12. JelleZijlstra
    closed this as completedon Nov 3, 2023
  13. aisk
    added a commit that references this issue on Feb 11, 2024

    pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (p…

    5b8aa03
  14. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-111654: remove redundant decref in LOAD_FROM_DICT_OR_DEREF (p…

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

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra

Labels

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 01402520 — 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.