Skip to content

List comprehensions cause subinterpreter crashes #135450

Closed
@ZeroIntensity

Description

@ZeroIntensity

Crash report

What happened?

If you use any list comprehension inside a subinterpreter (either through _interpreters or through interpreters), an assertion fails in _PyCode_CheckNoExternalState:

import _interpreters

interp = _interpreters.create()
_interpreters.run_string(interp, "[None for _ in []]")
python: Objects/codeobject.c:1982: _PyCode_CheckNoExternalState: Assertion `counts->locals.hidden.total == 0' failed.

This was originally causing failures in #134606. I think that assertion can be removed, because _PyCode_CheckNoExternalState seems to have no need for the number of hidden locals being zero.

cc @ericsnowcurrently

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-subinterpreterstype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions