Repository navigation
Python3.10.5 Pattern Matching Excessive Memory Consumption #93671
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Activity
- addedtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
on Jun 10, 2022 Wow. I can reproduce this on 3.11 and 3.12(main) too.
- added3.11only security fixesonly security fixes3.10 (EOL)end of lifeend of life3.12only security fixesonly security fixes
on Jun 10, 2022 This seems like a parser issue.
Linux perf output:
Samples: 36K of event 'cpu-clock:pppH', Event count (approx.): 9100000000 Overhead Command Shared Object Symbol 7.30% python python [.] _PyPegen_expect_token 6.68% python [kernel.kallsyms] [k] clear_page_erms 6.28% python [kernel.kallsyms] [k] __do_page_fault 4.64% python python [.] closed_pattern_rule 4.09% python python [.] _PyArena_Malloc 3.36% python python [.] signed_real_number_rule 3.09% python libc-2.31.so [.] _int_malloc 3.05% python python [.] or_pattern_rule 2.84% python python [.] unicodekeys_lookup_unicode
It might be the related to the depth of the statement, the following also produces a crash
match p: case [[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]: pass
Thanks, @tom-p-reichel and @dignissimus for the report and thanks a lot @kumaraditya303 for the initial investigation. Great work!
Reacted by Kumar Aditya and Talia Ringer- added a commit that references this issue
on Jun 10, 2022 - added a commit that references this issue
on Jun 26, 2022
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Crash report
While writing some code to match a particularly complicated AST, I accidentally wrote a function whose definition causes the Python 3.10.5 interpreter to rapidly consume memory. On my system, it consumed approximately 24 GBs of memory before being killed.
The function is as follows:
To replicate, paste the above function into a python file and run it.
Error messages
OOM killing produced no output, save for
Killed.Your environment