GNU bug report logs - #73204
Tree-sitter in clojure-ts-mode causes memory leak during parsing

Previous Next

Package: emacs;

Reported by: vinurs <hi <at> vinurs.me>

Date: Thu, 12 Sep 2024 18:04:01 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73204 in the body.
You can then email your comments to 73204 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#73204; Package emacs. (Thu, 12 Sep 2024 18:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to vinurs <hi <at> vinurs.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 12 Sep 2024 18:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: vinurs <hi <at> vinurs.me>
To: bug-gnu-emacs <at> gnu.org
Subject: Tree-sitter in clojure-ts-mode causes memory leak during
 parsing
Date: Fri, 13 Sep 2024 00:21:21 +0800
[Message part 1 (text/plain, inline)]
Hi,

I am using the precompiled version from https://emacsformacosx.com/builds 

https://emacsformacosx.com/emacs-builds/Emacs-2024-09-11_00-09-10-69e1aca041c57ba425425d31471e1c8f86d3bf04-universal.dmg

I have chosen the latest Emacs 30 version. The min configuration is as follows:

(add-to-list 'treesit-extra-load-path (expand-file-name "tree-sitter/" user-emacs-directory))
(add-to-list 'load-path "~/.emacs.d/site-lisp/clojure-ts-mode”) 
(require 'clojure-ts-mode) 
 ;; debug 
(setq debug-on-quit t)

and I only use clojure-ts-mode package

cd ~/.emacs.d/site-lisp
git clone https://github.com/clojure-emacs/clojure-ts-mode.git

Then, after opening Emacs, 
I opened the attached file b.clj, moved to line 57, 
and entered the following characters: 
(comment

At this point, Emacs freezes and becomes unresponsive. I noticed that Emacs' memory usage keeps increasing:
2024-09-12 21:12:23: 806624 KB
2024-09-12 21:12:28: 810720 KB
2024-09-12 21:12:33: 829840 KB
2024-09-12 21:12:38: 1582256 KB
2024-09-12 21:12:43: 4678816 KB
2024-09-12 21:12:48: 7831776 KB
2024-09-12 21:12:53: 10982384 KB
2024-09-12 21:12:58: 14140048 KB
2024-09-12 21:13:03: 17296176 KB
2024-09-12 21:13:08: 20440960 KB
2024-09-12 21:13:13: 23583008 KB
2024-09-12 21:13:18: 26726272 KB
2024-09-12 21:13:24: 29857312 KB
2024-09-12 21:13:29: 33011456 KB
2024-09-12 21:13:34: 36156624 KB
2024-09-12 21:13:39: 38685440 KB
2024-09-12 21:13:44: 34858560 KB
2024-09-12 21:13:49: 30892768 KB

Then, Emacs eventually gets killed by the system.

The bt.log is the information I was able to retrieve

------------

Sincerely,
[Message part 2 (text/html, inline)]
[b.clj (application/octet-stream, attachment)]
[bt.log (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73204; Package emacs. (Fri, 13 Sep 2024 04:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 73204 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: vinurs <hi <at> vinurs.me>
Cc: 73204 <at> debbugs.gnu.org
Subject: Re: bug#73204: Tree-sitter in clojure-ts-mode causes memory leak
 during parsing
Date: Thu, 12 Sep 2024 21:24:27 -0700

> On Sep 12, 2024, at 9:21 AM, vinurs <hi <at> vinurs.me> wrote:
> 
> Hi,
> 
> I am using the precompiled version from https://emacsformacosx.com/builds 
> https://emacsformacosx.com/emacs-builds/Emacs-2024-09-11_00-09-10-69e1aca041c57ba425425d31471e1c8f86d3bf04-universal.dmg
> 
> I have chosen the latest Emacs 30 version. The min configuration is as follows:
> 
> (add-to-list 'treesit-extra-load-path (expand-file-name "tree-sitter/" user-emacs-directory))
> (add-to-list 'load-path "~/.emacs.d/site-lisp/clojure-ts-mode”) 
> (require 'clojure-ts-mode) 
>  ;; debug 
> (setq debug-on-quit t)
> 
> and I only use clojure-ts-mode package
> 
> cd ~/.emacs.d/site-lisp
> git clone https://github.com/clojure-emacs/clojure-ts-mode.git
> 
> Then, after opening Emacs, 
> I opened the attached file b.clj, moved to line 57, 
> and entered the following characters: 
> (comment
> 
> At this point, Emacs freezes and becomes unresponsive. I noticed that Emacs' memory usage keeps increasing:
> 2024-09-12 21:12:23: 806624 KB
> 2024-09-12 21:12:28: 810720 KB
> 2024-09-12 21:12:33: 829840 KB
> 2024-09-12 21:12:38: 1582256 KB
> 2024-09-12 21:12:43: 4678816 KB
> 2024-09-12 21:12:48: 7831776 KB
> 2024-09-12 21:12:53: 10982384 KB
> 2024-09-12 21:12:58: 14140048 KB
> 2024-09-12 21:13:03: 17296176 KB
> 2024-09-12 21:13:08: 20440960 KB
> 2024-09-12 21:13:13: 23583008 KB
> 2024-09-12 21:13:18: 26726272 KB
> 2024-09-12 21:13:24: 29857312 KB
> 2024-09-12 21:13:29: 33011456 KB
> 2024-09-12 21:13:34: 36156624 KB
> 2024-09-12 21:13:39: 38685440 KB
> 2024-09-12 21:13:44: 34858560 KB
> 2024-09-12 21:13:49: 30892768 KB
> 
> Then, Emacs eventually gets killed by the system.
> The bt.log is the information I was able to retrieve
> ------------
> Sincerely,<b.clj><bt.log>

Hi vinurs, 

Thank you for your detailed report! This looks very similar to bug#72863, which we determined to be a tree-sitter bug. In both that bug and this, ts_parser_parse falls into an inf loop.

Your test file also uncovered another Emacs bug. I need fix this ASAP (emacs 30 pre-release is already out 😬). Once that’s fixed I’ll check if the hang is due to the same tree-sitter bug.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73204; Package emacs. (Sat, 14 Sep 2024 08:01:02 GMT) Full text and rfc822 format available.

Message #11 received at 73204 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: vinurs <hi <at> vinurs.me>
Cc: 73204 <at> debbugs.gnu.org
Subject: Re: bug#73204: Tree-sitter in clojure-ts-mode causes memory leak
 during parsing
Date: Sat, 14 Sep 2024 00:58:50 -0700

> On Sep 12, 2024, at 9:24 PM, Yuan Fu <casouri <at> gmail.com> wrote:
> 
> 
> 
>> On Sep 12, 2024, at 9:21 AM, vinurs <hi <at> vinurs.me> wrote:
>> 
>> Hi,
>> 
>> I am using the precompiled version from https://emacsformacosx.com/builds 
>> https://emacsformacosx.com/emacs-builds/Emacs-2024-09-11_00-09-10-69e1aca041c57ba425425d31471e1c8f86d3bf04-universal.dmg
>> 
>> I have chosen the latest Emacs 30 version. The min configuration is as follows:
>> 
>> (add-to-list 'treesit-extra-load-path (expand-file-name "tree-sitter/" user-emacs-directory))
>> (add-to-list 'load-path "~/.emacs.d/site-lisp/clojure-ts-mode”) 
>> (require 'clojure-ts-mode) 
>> ;; debug 
>> (setq debug-on-quit t)
>> 
>> and I only use clojure-ts-mode package
>> 
>> cd ~/.emacs.d/site-lisp
>> git clone https://github.com/clojure-emacs/clojure-ts-mode.git
>> 
>> Then, after opening Emacs, 
>> I opened the attached file b.clj, moved to line 57, 
>> and entered the following characters: 
>> (comment
>> 
>> At this point, Emacs freezes and becomes unresponsive. I noticed that Emacs' memory usage keeps increasing:
>> 2024-09-12 21:12:23: 806624 KB
>> 2024-09-12 21:12:28: 810720 KB
>> 2024-09-12 21:12:33: 829840 KB
>> 2024-09-12 21:12:38: 1582256 KB
>> 2024-09-12 21:12:43: 4678816 KB
>> 2024-09-12 21:12:48: 7831776 KB
>> 2024-09-12 21:12:53: 10982384 KB
>> 2024-09-12 21:12:58: 14140048 KB
>> 2024-09-12 21:13:03: 17296176 KB
>> 2024-09-12 21:13:08: 20440960 KB
>> 2024-09-12 21:13:13: 23583008 KB
>> 2024-09-12 21:13:18: 26726272 KB
>> 2024-09-12 21:13:24: 29857312 KB
>> 2024-09-12 21:13:29: 33011456 KB
>> 2024-09-12 21:13:34: 36156624 KB
>> 2024-09-12 21:13:39: 38685440 KB
>> 2024-09-12 21:13:44: 34858560 KB
>> 2024-09-12 21:13:49: 30892768 KB
>> 
>> Then, Emacs eventually gets killed by the system.
>> The bt.log is the information I was able to retrieve
>> ------------
>> Sincerely,<b.clj><bt.log>
> 
> Hi vinurs, 
> 
> Thank you for your detailed report! This looks very similar to bug#72863, which we determined to be a tree-sitter bug. In both that bug and this, ts_parser_parse falls into an inf loop.
> 
> Your test file also uncovered another Emacs bug. I need fix this ASAP (emacs 30 pre-release is already out 😬). Once that’s fixed I’ll check if the hang is due to the same tree-sitter bug.
> 
> Yuan

I fixed the bug I discovered; and guess what, that totally fixed this bug! So this bug isn’t caused by the tree-sitter bug, despite having similar symptoms.

When the next pretest comes out, please give it a try and see if you can still see the bug. Or you can clone the emacs-30 branch and check it out now.

Thanks again for the report! Would’ve been really bad if we didn’t discover this bug before releasing Emacs 30.

Yuan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73204; Package emacs. (Sat, 14 Sep 2024 09:16:02 GMT) Full text and rfc822 format available.

Message #14 received at 73204 <at> debbugs.gnu.org (full text, mbox):

From: vinurs <hi <at> vinurs.me>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 73204 <at> debbugs.gnu.org
Subject: Re: bug#73204: Tree-sitter in clojure-ts-mode causes memory
 leak during parsing
Date: Sat, 14 Sep 2024 17:14:59 +0800
[Message part 1 (text/plain, inline)]
Hi,
Thank you for your fix! I just compiled the latest Emacs-30 code and tested several files that had problems before. It’s working very well so far.

------------

Sincerely,



Haiyuan Zhang, Vinurs

BinaryBrain LLC


开 2024年9月14日 在 15:59:05, Yuan Fu (casouri <at> gmail.com) 写到:



> On Sep 12, 2024, at 9:24 PM, Yuan Fu <casouri <at> gmail.com> wrote:  
>  
>  
>  
>> On Sep 12, 2024, at 9:21 AM, vinurs <hi <at> vinurs.me> wrote:  
>>  
>> Hi,  
>>  
>> I am using the precompiled version from https://emacsformacosx.com/builds  
>> https://emacsformacosx.com/emacs-builds/Emacs-2024-09-11_00-09-10-69e1aca041c57ba425425d31471e1c8f86d3bf04-universal.dmg  
>>  
>> I have chosen the latest Emacs 30 version. The min configuration is as follows:  
>>  
>> (add-to-list 'treesit-extra-load-path (expand-file-name "tree-sitter/" user-emacs-directory))  
>> (add-to-list 'load-path "~/.emacs.d/site-lisp/clojure-ts-mode”)  
>> (require 'clojure-ts-mode)  
>> ;; debug  
>> (setq debug-on-quit t)  
>>  
>> and I only use clojure-ts-mode package  
>>  
>> cd ~/.emacs.d/site-lisp  
>> git clone https://github.com/clojure-emacs/clojure-ts-mode.git  
>>  
>> Then, after opening Emacs,  
>> I opened the attached file b.clj, moved to line 57,  
>> and entered the following characters:  
>> (comment  
>>  
>> At this point, Emacs freezes and becomes unresponsive. I noticed that Emacs' memory usage keeps increasing:  
>> 2024-09-12 21:12:23: 806624 KB  
>> 2024-09-12 21:12:28: 810720 KB  
>> 2024-09-12 21:12:33: 829840 KB  
>> 2024-09-12 21:12:38: 1582256 KB  
>> 2024-09-12 21:12:43: 4678816 KB  
>> 2024-09-12 21:12:48: 7831776 KB  
>> 2024-09-12 21:12:53: 10982384 KB  
>> 2024-09-12 21:12:58: 14140048 KB  
>> 2024-09-12 21:13:03: 17296176 KB  
>> 2024-09-12 21:13:08: 20440960 KB  
>> 2024-09-12 21:13:13: 23583008 KB  
>> 2024-09-12 21:13:18: 26726272 KB  
>> 2024-09-12 21:13:24: 29857312 KB  
>> 2024-09-12 21:13:29: 33011456 KB  
>> 2024-09-12 21:13:34: 36156624 KB  
>> 2024-09-12 21:13:39: 38685440 KB  
>> 2024-09-12 21:13:44: 34858560 KB  
>> 2024-09-12 21:13:49: 30892768 KB  
>>  
>> Then, Emacs eventually gets killed by the system.  
>> The bt.log is the information I was able to retrieve  
>> ------------  
>> Sincerely,<b.clj><bt.log>  
>  
> Hi vinurs,  
>  
> Thank you for your detailed report! This looks very similar to bug#72863, which we determined to be a tree-sitter bug. In both that bug and this, ts_parser_parse falls into an inf loop.  
>  
> Your test file also uncovered another Emacs bug. I need fix this ASAP (emacs 30 pre-release is already out 😬). Once that’s fixed I’ll check if the hang is due to the same tree-sitter bug.  
>  
> Yuan  

I fixed the bug I discovered; and guess what, that totally fixed this bug! So this bug isn’t caused by the tree-sitter bug, despite having similar symptoms.  

When the next pretest comes out, please give it a try and see if you can still see the bug. Or you can clone the emacs-30 branch and check it out now.  

Thanks again for the report! Would’ve been really bad if we didn’t discover this bug before releasing Emacs 30.  

Yuan  

[Message part 2 (text/html, inline)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 28 Sep 2024 08:53:02 GMT) Full text and rfc822 format available.

Notification sent to vinurs <hi <at> vinurs.me>:
bug acknowledged by developer. (Sat, 28 Sep 2024 08:53:02 GMT) Full text and rfc822 format available.

Message #19 received at 73204-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: vinurs <hi <at> vinurs.me>
Cc: casouri <at> gmail.com, 73204-done <at> debbugs.gnu.org
Subject: Re: bug#73204: Tree-sitter in clojure-ts-mode causes memory leak
 during parsing
Date: Sat, 28 Sep 2024 11:51:59 +0300
> Cc: 73204 <at> debbugs.gnu.org
> Date: Sat, 14 Sep 2024 17:14:59 +0800
> From: vinurs <hi <at> vinurs.me>
> 
> Hi,
> Thank you for your fix! I just compiled the latest Emacs-30 code and tested several files that had problems
> before. It’s working very well so far.
> 
> ------------
> 
> Sincerely,
> 
> Haiyuan Zhang, Vinurs
> 
> BinaryBrain LLC

Thanks, so I'm now closing this bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 26 Oct 2024 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 237 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.