StanFromIreland · GitHub

Crash report

What happened?

Found by OSS Fuzz in 491369109.

When running the below reproducer with the PyCF_IGNORE_COOKIE and PyCF_TYPE_COMMENTS flags, you get:

>>> a=1 #type: \x80
python: Python/ast.c:1051: _PyAST_Validate: Assertion `!PyErr_Occurred()' failed.
Fatal Python error: Aborted

This occurs because NEW_TYPE_COMMENT() sets p->error_indicator and returns NULL (_PyPegen_new_type_comment() fails on decoding, and returns NULL). However since the field is optional, parsing succeeds. Our current error check does not account for this case.

I will send a patch shortly.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

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

No response

Linked PRs

Read the original on github.com ↗