Staging
v0.8.1
https://github.com/python/cpython
Revision 8de34cdb952a2e3b8d7a9a213845cad01a8cece3 authored by Pablo Galindo on 02 September 2020, 20:30:51 UTC, committed by GitHub on 02 September 2020, 20:30:51 UTC
This program can segfault the parser by stack overflow:

```
import ast

code = "f(" + ",".join(['a' for _ in range(100000)]) + ")"
print("Ready!")
ast.parse(code)
```

the reason is that the rule for arguments has a simple recursion when collecting args:

args[expr_ty]:
    [...]
    | a=named_expression b=[',' c=args { c }] {
        [...] }.
(cherry picked from commit 4a97b1517a6b5ff22e2984b677a680b07ff0ce11)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
1 parent a763ee3
History
Tip revision: 8de34cdb952a2e3b8d7a9a213845cad01a8cece3 authored by Pablo Galindo on 02 September 2020, 20:30:51 UTC
[3.9] bpo-41690: Use a loop to collect args in the parser instead of recursion (GH-22053) (GH-22067)
Tip revision: 8de34cd
File Mode Size
abstract.h -rw-r--r-- 13.9 KB
bytearrayobject.h -rw-r--r-- 769 bytes
bytesobject.h -rw-r--r-- 4.0 KB
ceval.h -rw-r--r-- 1.5 KB
code.h -rw-r--r-- 6.8 KB
dictobject.h -rw-r--r-- 3.7 KB
fileobject.h -rw-r--r-- 951 bytes
fileutils.h -rw-r--r-- 3.9 KB
frameobject.h -rw-r--r-- 3.0 KB
import.h -rw-r--r-- 1.4 KB
initconfig.h -rw-r--r-- 16.6 KB
interpreteridobject.h -rw-r--r-- 456 bytes
listobject.h -rw-r--r-- 1.3 KB
methodobject.h -rw-r--r-- 1.4 KB
object.h -rw-r--r-- 18.9 KB
objimpl.h -rw-r--r-- 4.4 KB
pyerrors.h -rw-r--r-- 5.0 KB
pylifecycle.h -rw-r--r-- 2.0 KB
pymem.h -rw-r--r-- 3.4 KB
pystate.h -rw-r--r-- 9.9 KB
sysmodule.h -rw-r--r-- 575 bytes
traceback.h -rw-r--r-- 473 bytes
tupleobject.h -rw-r--r-- 1.0 KB
unicodeobject.h -rw-r--r-- 44.5 KB

back to top