classification
Title: Custom AST can crash Python (debug build)
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, miss-islington, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-06-05 09:46 by BTaskaya, last changed 2020-06-06 17:26 by pablogsal. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20649 merged BTaskaya, 2020-06-05 09:50
PR 20675 merged miss-islington, 2020-06-06 12:44
PR 20676 merged miss-islington, 2020-06-06 12:44
Messages (5)
msg370753 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python triager) Date: 2020-06-05 09:46
import ast
t = ast.fix_missing_locations(ast.Expression(ast.Name("True", ast.Load())))
compile(t, "<t>", "eval")

compilation of this AST can crash the interpreter for 3.8+

test_constant_as_name (test.test_ast.AST_Tests) ... python: Python/compile.c:3559: compiler_nameop: Assertion `!_PyUnicode_EqualToASCIIString(name, "None") && !_PyUnicode_EqualToASCIIString(name, "True") && !_PyUnicode_EqualToASCIIString(name, "False")' failed.
Fatal Python error: Aborted

I've encountered this while running test suite of 'pytest' with the current master, so I guess there are some usages related this out there. IMHO we should validate this on the PyAST_Validate step to prevent this kind of crashes.
msg370759 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python triager) Date: 2020-06-05 10:23
cross-linking pytest issue: https://github.com/pytest-dev/pytest/issues/7322
msg370819 - (view) Author: miss-islington (miss-islington) Date: 2020-06-06 12:44
New changeset 68874a8502da440a1dc4746cf73262648b870aee by Batuhan Taskaya in branch 'master':
bpo-40870: Invalidate usage of some constants with ast.Name (GH-20649)
https://github.com/python/cpython/commit/68874a8502da440a1dc4746cf73262648b870aee
msg370835 - (view) Author: miss-islington (miss-islington) Date: 2020-06-06 17:04
New changeset 90ee51f1cd9e63cfe0f402392612f50fc1bea747 by Miss Islington (bot) in branch '3.9':
bpo-40870: Invalidate usage of some constants with ast.Name (GH-20649)
https://github.com/python/cpython/commit/90ee51f1cd9e63cfe0f402392612f50fc1bea747
msg370836 - (view) Author: miss-islington (miss-islington) Date: 2020-06-06 17:04
New changeset 83a9ba442662c2a030b45955f3dd24ff4b24bb61 by Miss Islington (bot) in branch '3.8':
bpo-40870: Invalidate usage of some constants with ast.Name (GH-20649)
https://github.com/python/cpython/commit/83a9ba442662c2a030b45955f3dd24ff4b24bb61
History
Date User Action Args
2020-06-06 17:26:34pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-06-06 17:04:50miss-islingtonsetmessages: + msg370836
2020-06-06 17:04:45miss-islingtonsetmessages: + msg370835
2020-06-06 12:44:41miss-islingtonsetpull_requests: + pull_request19891
2020-06-06 12:44:34miss-islingtonsetpull_requests: + pull_request19890
2020-06-06 12:44:19miss-islingtonsetnosy: + miss-islington
messages: + msg370819
2020-06-05 10:23:26BTaskayasetmessages: + msg370759
2020-06-05 09:50:55BTaskayasetkeywords: + patch
stage: patch review
pull_requests: + pull_request19869
2020-06-05 09:50:26BTaskayasetnosy: + serhiy.storchaka, pablogsal

type: behavior
components: + Interpreter Core
versions: + Python 3.8, Python 3.9, Python 3.10
2020-06-05 09:46:27BTaskayacreate