Skip to content

[3.12] Lambda generators cause assertion failure: python: Objects/genobject.c:400: gen_close: Assertion exception_handler_depth > 0' failed.` #119897

Description

@mgorny

Crash report

What happened?

When CPython 3.12 is built with assertions enabled, the following snippet causes the interpreter to crash:

x = lambda: (yield 3)
next(x())
$ ./python /tmp/LambdasTest.py 
python: Objects/genobject.c:400: gen_close: Assertion `exception_handler_depth > 0' failed.
Aborted (core dumped)

This doesn't happen with 3.11 or with main. From a quick bisect:

This was triggered in the wild by Nuitka's test suite: Nuitka/Nuitka#2893.

CC @iritkatriel

CPython versions tested on:

3.12

Operating systems tested on:

Linux

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

Python 3.12.3+ (heads/3.12:6d9677d78e, Jun 1 2024, 11:06:51) [GCC 14.1.1 20240516]

Linked PRs

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Jun 1, 2024
  2. added
    3.12only security fixes
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on Jun 1, 2024
  3. mgorny commented on Jun 10, 2024

    @mgorny
    ContributorAuthor

    Gentle ping.

  4. mgorny commented on Jun 12, 2024

    @mgorny
    ContributorAuthor

    Given no reply, I'm going to revert this change in Gentoo. Hope that doesn't cause more issues.

  5. added a commit that references this issue on Jun 12, 2024
  6. self-assigned this
    on Jun 13, 2024
  7. iritkatriel commented on Jun 13, 2024

    @iritkatriel
    Member

    Thanks. I agree, let's revert the bad commit in 3.12.

  8. added a commit that references this issue on Jun 18, 2024
  9. added a commit that references this issue on Jun 18, 2024
  10. added a commit that references this issue on Jun 18, 2024
  11. iritkatriel commented on Jun 18, 2024

    @iritkatriel
    Member

    Thanks.

  12. mgorny commented on Jun 18, 2024

    @mgorny
    ContributorAuthor

    Thank you!

  13. added a commit that references this issue on Jun 18, 2024
  14. added a commit that references this issue on Jun 30, 2024
  15. added a commit that references this issue on Jul 11, 2024
  16. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA 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