Instagram / Instagram/LibCST

Stack overflow when parsing an expression

Open
#1,000 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.9k
Forks
229
PR merge metrics
No merged PRs in 30d

Description

Below I've attached a real file that has been published on PyPI. It contains an impressively gigantic expression.

[huge.txt](https://github.com/Instagram/LibCST/files/12445264/huge.txt)

Parsing this file with the current libcst master branch causes a stack overflow. After some debugging, this appears to be caused by the `cache_left_rec` macro cloning the expression ([here](https://github.com/kevinmehall/rust-peg/blob/c870876adc9a9601f14dfa3e13c5a691ddfeb8ee/peg-macros/translate.rs#L292-L294)), which in this case causes a _gigantic_ recursive clone of the expression, eventually overflowing the stack.

Screenshot 2023-08-26 at 12 40 04

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.