all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Denis Zubarev <dvzubarev@yandex.ru>, 67977@debbugs.gnu.org
Subject: bug#67977: 30.0.50; tree-sitter: Emacs crashes when accessing treesit-nodes in a narrowed buffer
Date: Sat, 23 Dec 2023 19:00:34 -0800	[thread overview]
Message-ID: <08D379EF-1556-4498-8E60-F7972A25752A@gmail.com> (raw)
In-Reply-To: <1DE32BF7-75D8-4F49-975D-53C782D26016@gmail.com>



> On Dec 23, 2023, at 12:08 AM, Yuan Fu <casouri@gmail.com> wrote:
> 
> 
> 
>> On Dec 22, 2023, at 11:26 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> 
>>> From: Denis Zubarev <dvzubarev@yandex.ru>
>>> Date: Sat, 23 Dec 2023 02:18:20 +0300
>>> 
>>> 1. emacs -Q
>>> 2. M-x find-file /tmp/t.py
>>> 3. paste there
>>> start=1
>>> def _init(self, param1, param2, param3=False):
>>>   self._param1 = param2
>>>   self._param2 = param2
>>>   self._param3 = param3
>>> 4. python-ts-mode
>>> 5. select two last lines and M-x narrow-to-region
>>> 6. answer all prompts
>>> 7. Put cursor on the last self
>>> 8. M-x eval-expression
>>> (progn
>>> (setq temp-node (treesit-node-at (point)))
>>> (sit-for 2)
>>> (garbage-collect)
>>> (message "node %s" temp-node))
>>> 9. Emacs crashes or prints node that contains garbage
>> 
>> Thanks.
>> 
>> Yuan, this also happens on the emacs-29 branch, so we should try
>> fixing this crash ASAP.
> 
> Yeah. The node wants to print it’s type name (with ts_node_type), which access it’s parse tree, but the tree is already freed, that means the node is outdated and shouldn’t try to print it’s type name, but should rather print “outdated”.
> 
> But simply narrowing the buffer shouldn’t reparse the buffer and cause the parse tree to be freed. Anyway, let me see what’s going on.


I pushed a fix and now it shouldn’t crash anymore. However, I’m yet not sure why at some point the buffer was widened. Is there any way to track who called widen?

Yuan




  reply	other threads:[~2023-12-24  3:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 23:18 bug#67977: 30.0.50; tree-sitter: Emacs crashes when accessing treesit-nodes in a narrowed buffer Denis Zubarev
2023-12-23  7:26 ` Eli Zaretskii
2023-12-23  8:08   ` Yuan Fu
2023-12-24  3:00     ` Yuan Fu [this message]
2023-12-24  7:11       ` Eli Zaretskii
2023-12-27  4:15         ` Yuan Fu
2023-12-27 12:57           ` Eli Zaretskii
2023-12-28  8:07             ` Yuan Fu
2023-12-28 11:44               ` Dmitry Gutov
2023-12-28 13:53                 ` Eli Zaretskii
2023-12-28 16:16                   ` Dmitry Gutov
2023-12-29  7:00                     ` Yuan Fu
2023-12-29 12:48                       ` Dmitry Gutov
2023-12-30  4:35                         ` Yuan Fu
2023-12-30 16:21       ` Denis Zubarev
2023-12-30 20:23         ` Yuan Fu
2023-12-31  0:08           ` Dmitry Gutov
2023-12-31 10:39           ` Denis Zubarev
2023-12-31 12:56             ` Eli Zaretskii
2023-12-31 13:40             ` Dmitry Gutov
2024-01-02  4:46               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-02 13:34                 ` Dmitry Gutov
2024-01-02 22:58                   ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08D379EF-1556-4498-8E60-F7972A25752A@gmail.com \
    --to=casouri@gmail.com \
    --cc=67977@debbugs.gnu.org \
    --cc=dvzubarev@yandex.ru \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.