8000 Segmentation Fault when statically nesting EXACTLY 20 content managers. · Issue #118544 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Segmentation Fault when statically nesting EXACTLY 20 content managers. #118544
@babygrimes

Description

@babygrimes

Bug report

Bug description:

# Add a code block here, if required
async def test():
    async with (
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            cm(),
            # cm(),
    ):
        pass

The above code (with the final cm() commented out) will cause a Segmentation Fault on Ubuntu 22.04. This works as expected on Python3.11.

[dmgrime@dave-laptop:~]$ python3.11 breakme.py
[dmgrime@dave-laptop:~]$ python3.12 breakme.py
Segmentation fault

Note: commenting out an additional cm() works as expected in both Python3.11 and Python3.12 (no exception, no seg fault).

[dmgrime@dave-laptop:~]$ py
5A49
thon3.11 breakme.py
[dmgrime@dave-laptop:~]$ python3.12 breakme.py
[dmgrime@dave-laptop:~]$

Note: uncommenting the final cm() works as expected in both Python3.11 and Python3.12 (exception but no seg fault).

[dmgrime@dave-laptop:~]$ python3.11 breakme.py
  File "/home/dmgrime/breakme.py", line 2
    async with (
    ^^^^^^^^^^^^
SyntaxError: too many statically nested blocks
[dmgrime@dave-laptop:~]$ python3.12 breakme.py
  File "/home/dmgrime/breakme.py", line 2
    async with (
    ^^^^^^^^^^^^
SyntaxError: too many statically nested blocks
[dmgrime@dave-laptop:~]$

CPython versions tested on:

3.11, 3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0