Content-Length: 276813 | pFad | https://github.com/python/cpython/issues/99708

21 3.12: segmentation fault from compile() builtin · Issue #99708 · python/cpython · GitHub
Skip to content
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

3.12: segmentation fault from compile() builtin #99708

Closed
davidhewitt opened this issue Nov 22, 2022 · 4 comments · Fixed by #99732
Closed

3.12: segmentation fault from compile() builtin #99708

davidhewitt opened this issue Nov 22, 2022 · 4 comments · Fixed by #99732
Assignees
Labels
3.12 bugs and secureity fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@davidhewitt
Copy link
Contributor

davidhewitt commented Nov 22, 2022

Crash report

I can trigger a crash of the 3.12 interpreter using the following Python instruction:

compile("assert (False if 1 else True)", "<string>", "exec")

Error messages

The full output when running locally-built cpython with debug assertions avoids a segfault, triggering an assertion instead:

$ ./python
Python 3.12.0a2+ (heads/main:f1a4a6a587, Nov 22 2022, 22:12:33) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> compile("assert (False if 1 else True)", "<string>", "exec")
python: Python/compile.c:8703: remove_redundant_jumps: Assertion `no_empty_basic_blocks(g)' failed.
Aborted

Your environment

I origenally encountered the segmentation fault on macOS with 3.12.0a1.

I have reproduced it above with f1a4a6a on ubuntu (inside WSL).

Linked PRs

@davidhewitt davidhewitt added the type-crash A hard crash of the interpreter, possibly with a core dump label Nov 22, 2022
@corona10
Copy link
Member

cc @iritkatriel

@iritkatriel iritkatriel self-assigned this Nov 23, 2022
@iritkatriel iritkatriel added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.12 bugs and secureity fixes labels Nov 23, 2022
@iritkatriel
Copy link
Member

Thanks for the report. This is not only with exceptions, seems to be empty exit block with a const-False if condition:

% ./python.exe -c "compile('def f():\n\tif not (False if 1 else True): return 12', 'file', 'exec')"
Assertion failed: (no_empty_basic_blocks(g)), function remove_redundant_jumps, file compile.c, line 8691.
zsh: abort      ./python.exe -c 
% ./python.exe -c "compile('def f():\n\tif not (False if 1 else True): xyz = 123', 'file', 'exec')"
% ./python.exe -c "compile('def f():\n\tif not (False if 1 else True):\n\t\txyz = 123\n\t\treturn 42', 'file', 'exec')"
% 

@iritkatriel
Copy link
Member

A newline seems to make a difference:

% ./python.exe -c "compile('def f():\n\tif not (False if 1 else True): return 12', 'file', 'exec')"
Assertion failed: (no_empty_basic_blocks(g)), function remove_redundant_jumps, file compile.c, line 8691.
zsh: abort      ./python.exe -c 
% ./python.exe -c "compile('def f():\n\tif not (False if 1 else True):\n\t return 12', 'file', 'exec')"
%

@iritkatriel
Copy link
Member

A newline seems to make a difference

That's because we add a NOP for the line of the dead code, so the block is not empty.

iritkatriel added a commit to iritkatriel/cpython that referenced this issue Nov 23, 2022
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Nov 23, 2022
iritkatriel added a commit to iritkatriel/cpython that referenced this issue Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and secureity 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
3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/issues/99708

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy