GNU bug report logs - #71681
29.3.50; tree-sitter crash

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Thu, 20 Jun 2024 16:43:01 UTC

Severity: normal

Found in version 29.3.50

Full log


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

From: Juri Linkov <juri <at> linkov.net>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 71681 <at> debbugs.gnu.org
Subject: Re: bug#71681: 29.3.50; tree-sitter crash
Date: Sun, 30 Jun 2024 19:15:28 +0300
> Finally figured out why. It’s not tree-sitter’s problem, but
> ours. I reduced the crash to a signal and pushed the fix to
> emacs-30. Next I’ll make sure the signal is properly handled. Below
> quoting the commit message:
>
> The immediate cause of the crash is that tree-sitter accessed a node's
> tree, but the tree is already deleted.
>
> What happended, I think, is this:
>
> 1. Buffer modified, parser->need_reparse set to true,
> parser->timestamp incremented.
> 2. A node is created from the parser, this node has the old tree but
> the _new_ timestamp (bad!).
> 3. Parser re-parses (treesit_ensure_parsed), new tree created, old
> tree deleted.
> 4. Ftreesit_query_capture accessed the old node, and the old tree,
> crash.
>
> We shouldn't bump the parser timestamp when we set
> parser->need_reparse to true; instead, we should bump the timestamp
> when we actually reparsed and created a new tree.

Thank you very much.  I confirm there are no crashes anymore.




This bug report was last modified 107 days ago.

Previous Next


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