Subject: Re: bug#59426: 29.0.50; [tree-sitter] Some functions exceed maximum recursion limit

From: Yuan Fu <[email-masked]>
Date: Wed, 23 Nov 2022 10:46:13 -0800

> On Nov 23, 2022, at 2:40 AM, Mattias Engdegård <[email-masked]> wrote:
> 
> 23 nov. 2022 kl. 00.19 skrev Yuan Fu <[email-masked]>:
> 
>> It’s a machine generated file with syntax that tree-sitter-c can’t handle very well. The file is from bug#45248.
> 
> If you mean https://gitlab.com/wireshark/wireshark/-/raw/master/epan/dissectors/packet-rrc.c, then the parse tree would certainly be wide but not at all tall as far as I can tell. There is a fairly long array initialiser in there, but I've seen worse -- and it shouldn't be treated recursively, should it?

It shouldn’t, but tree-sitter thinks some closing brackets are erroneous and skips them when parsing (it skips erroneous tokens in the hope to parse the rest of the file despite local errors). So a 10k wide tree becomes 10k tall.

We can submit a bug repot to tree-sitter-c (“maybe don’t skip closing brackets even there is error, or somthing”), but that’s another story.

Yuan