bug#72863: 30.0.50; tree-sitter elixir-ts-mode hangs and memory leak on some elixir and heex code

2024-09-04 Thread mail
I can confirm that I never had such problems in heex-ts-mode but only with 
inline heex in elixir-ts-mode.

> On Sep 4, 2024, at 10:39 AM, Wilhelm Kirschbaum  wrote:
> 
> 
> 
> On Thu, Aug 29, 2024 at 8:14 AM Yuan Fu  > wrote:
>> 
>> 
>> > On Aug 28, 2024, at 10:09 PM, Eli Zaretskii > > > wrote:
>> > 
>> >> From: m...@ssbb.me 
>> >> Date: Thu, 29 Aug 2024 06:57:38 +0400
>> >> 
>> >> Code in attached file cause Emacs to hang and memory leak infinitely
>> >> while editing. Try to open this code in elixir-ts-mode and move cursor
>> >> on line 6 (between <:loading>  ) and type char by char:
>> >> 
>> >> <.some_component a={
>> >> 
>> >> (for some reason it does not happen with electric-pair-mode when {}
>> >> inserted automatically).
>> >> 
>> >> I am able to reproduce this with -Q on few different machines (Linux and
>> >> MacOS) and Emacs 29, 30.0.5 and current HEAD.
>> >> 
>> >> C-g does nothing (including with debug-on-quit and sending SIGUSR2)
>> >> 
>> >> At the same time I can't reproduce this in other tree-sitter based 
>> >> editors.
>> >> 
>> >> I got this sample code sample from elixir-ts-mode repo but now it's moved
>> >> to the Emacs core so seems to be out of scope of Github repo issues.
>> >> 
>> >> Attaching samle code and LLDB backtrace. 
>> >> Also attaching report from built-in MacOS crash reporting tool just in 
>> >> case.
>> > 
>> > Thanks.
>> > 
>> > Wilhelm and Yuan, could you please look into this soon?
>> 
>> That’s bizarre, might have some bug around ranges. I’m looking into this. 
>> Hopefully I can figure it out in a few days :-(
>> 
>> Yuan
> 
> I can reproduce the issue by following the above instructions, but need to do 
> some digging. It only seems to be the case with embedded heex and not with 
> heex-ts-mode by itself.
> 
> WIlhelm
> 
> 
> 



bug#72863: 30.0.50; tree-sitter elixir-ts-mode hangs and memory leak on some elixir and heex code

2024-09-11 Thread mail
Wow, thank you so much for diving into this issue! I'll keep track of it in 
tree-sitter repo from now on.

It seems like other integrations somehow manage to avoid hanging or crashing 
the main process, so it doesn't affect them?

I just checked in the Zed editor again to confirm. When I type a={, it fails to 
highlight the rest of the embedded HEEX (but only within the current function) 
though.


> On Sep 11, 2024, at 7:45 AM, Yuan Fu  wrote:
> 
> 
> 
>> On Sep 8, 2024, at 12:48 AM, Yuan Fu  wrote:
>> 
>> 
>> 
>>> On Sep 8, 2024, at 12:02 AM, Eli Zaretskii  wrote:
>>> 
 From: Yuan Fu 
 Date: Sat, 7 Sep 2024 22:57:29 -0700
 Cc: m...@ssbb.me,
 wkirschb...@gmail.com,
 72...@debbugs.gnu.org
 
 
 
> On Sep 7, 2024, at 10:54 PM, Eli Zaretskii  wrote:
> 
>> From: Yuan Fu 
>> Date: Sat, 7 Sep 2024 22:44:53 -0700
>> Cc: Wilhelm Kirschbaum ,
>> Eli Zaretskii ,
>> 72...@debbugs.gnu.org
>> 
>> Meanwhile, I want to push the fix for the other bug I discovered to 
>> emacs-30. Eli, I wrote a debugging function that prints parser states, 
>> naturally this function isn’t called anywhere so there’ll be a compiler 
>> warning, what should I do in this case?
> 
> Why would there be a compiler warning?  What kind of warning?
 
 A function-not-used warning. Maybe it’s an lldb thing?
>>> 
>>> If the function is not static, there should be no such warning.
>> 
>> Ah, you’re right, I marked it static. Thanks!
>> 
>> Yuan
> 
> Good news: not an Emacs bug. Bad news: a tree-sitter bug. Turns out I made an 
> error in my test program, which is the reason why Emacs hangs but the test 
> program doesn’t. Once I fixed the error, the test program hangs too. I 
> submitted a bug report to tree-sitter: 
> https://github.com/tree-sitter/tree-sitter/issues/3620
> 
> I can finally sleep soundly at night now; and I guess tree-sitter dev will 
> start having sleepless nights :-)
> 
> Yuan
>