Skip to content

Failed assertion in codegen_nameop #133516

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
TERESH1 opened this issue May 6, 2025 · 2 comments
Closed

Failed assertion in codegen_nameop #133516

TERESH1 opened this issue May 6, 2025 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-parser type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@TERESH1
Copy link
Contributor

TERESH1 commented May 6, 2025

Crash report

What happened?

>>> compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
python: Python/codegen.c:3189: int codegen_nameop(compiler *, location, identifier, expr_context_ty): Assertion `!_PyUnicode_EqualToASCIIString(name, "None") && !_PyUnicode_EqualToASCIIString(name, "True") && !_PyUnicode_EqualToASCIIString(name, "False")' failed.
Aborted (core dumped)

The _PyPegen_new_identifier function normalizes to NFKC non-ASCII strings, which allows you to set keywords (None, True, False) with a different character representation as an identifier.

Found by Linux Verification Center (portal.linuxtesting.ru) with libFuzzer
Author S.Tereshin ([email protected])

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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

Python 3.14.0a7+ (heads/main-dirty:3dfed2309, May 6 2025, 13:36:58) [Clang 18.1.8 (Fedora 18.1.8-1.fc40)]

Linked PRs

@TERESH1 TERESH1 added the type-crash A hard crash of the interpreter, possibly with a core dump label May 6, 2025
TERESH1 added a commit to TERESH1/cpython that referenced this issue May 6, 2025
@ZeroIntensity
Copy link
Member

I couldn't reproduce this:

Python 3.14.0a7+ (heads/main:3dfed23092, May  6 2025, 16:44:44) [GCC 14.2.1 20250207] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: identifier field can't represent 'False' constant

@TERESH1
Copy link
Contributor Author

TERESH1 commented May 7, 2025

I couldn't reproduce this:

Python 3.14.0a7+ (heads/main:3dfed23092, May  6 2025, 16:44:44) [GCC 14.2.1 20250207] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: identifier field can't represent 'False' constant

Configure without --with-pydebug, only --with-assertions

@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 7, 2025
pablogsal pushed a commit that referenced this issue May 7, 2025
…` are used as an identifier after NFKC normalization (#133523)
pablogsal pushed a commit that referenced this issue May 7, 2025
…r `None` are used as an identifier after NFKC normalization (GH-133523) (#133596)
TERESH1 added a commit to TERESH1/cpython that referenced this issue May 8, 2025
…lse` or `None` are used as an identifier after NFKC normalization (pythonGH-133523)

(cherry picked from commit d9b0b07)
TERESH1 added a commit to TERESH1/cpython that referenced this issue May 8, 2025
…lse` or `None` are used as an identifier after NFKC normalization (pythonGH-133523)

(cherry picked from commit d9b0b07)
pablogsal pushed a commit that referenced this issue May 8, 2025
…r `None` are used as an identifier after NFKC normalization (GH-133523) (#133615)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-parser type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

4 participants