Subject: Re: bug#71679: 29.3; treesit-node-child function chokes and crashes emacs for nodes with large number of child nodes

From: Eli Zaretskii <[email-masked]>
Date: Thu, 20 Jun 2024 19:02:41 +0300

> Date: Thu, 20 Jun 2024 09:08:31 -0600
> From:  Mauritz Stenek via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> 
> The function `treesit-node-child` chokes when parsing a 
> tree-sitter node with a large number of child nodes -- ie a large 
> buffer string -- and causes emacs to crash.
> 
> To reproduce, load a large source file, and run this:
> 
> ```
> (let ((string (with-current-buffer
>                   "<buffer name with a large number or lines>"
>                 (buffer-string)))
>       (node (treesit-parse-string string <LANGUAGE>)))
>   (treesit-node-child node 0 t))
> ```
> (this assumes that the LANGUAGE-ts-mode and the LANGUAGE grammar 
> are installed).
> 
> This crashed my emacs; here's the backtrace:

Thanks, but please tell exactly which grammar you used and post a
"file with a large number of lines" that can be used to reproduce
this.

The backtrace you posted can only be interpreted on your system, so it
is important to have a reproduction recipe for us to look into the
problem.