Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mgorny opened this issue Jun 1, 2024 · 5 comments
Assignees
Labels
3.12 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@mgorny
Copy link
Contributor

mgorny commented Jun 1, 2024

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

@mgorny mgorny added the type-crash A hard crash of the interpreter, possibly with a core dump label Jun 1, 2024
@Eclips4 Eclips4 added 3.12 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 1, 2024
@mgorny
Copy link
Contributor Author

mgorny commented Jun 10, 2024

Gentle ping.

@mgorny
Copy link
Contributor Author

mgorny commented Jun 12, 2024

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

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Jun 12, 2024
Includes a revert to an optimization fix that causes crashes
in USE=debug builds.

Bug: python/cpython#119897
Signed-off-by: Michał Górny <[email protected]>
@iritkatriel iritkatriel self-assigned this Jun 13, 2024
@iritkatriel
Copy link
Member

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

@iritkatriel
Copy link
Member

Thanks.

@mgorny
Copy link
Contributor Author

mgorny commented Jun 18, 2024

Thank you!

iritkatriel added a commit that referenced this issue Jun 18, 2024
#120673)

gh-119897: Add test for lambda generator invocation (GH-120658)
(cherry picked from commit 73dc1c6)


gh-120467: Add test for lambda generator invocation

Co-authored-by: Irit Katriel <[email protected]>
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

3 participants