all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Vincenzo Pupillo <v.pupillo@gmail.com>
To: juri@linkov.net, 71681@debbugs.gnu.org
Cc: casouri@gmail.com
Subject: bug#71681: 29.3.50; tree-sitter crash
Date: Sun, 30 Jun 2024 21:22:07 +0200	[thread overview]
Message-ID: <2331247.vFx2qVVIhK@fedora> (raw)
In-Reply-To: <25A37A53-DD48-4E34-ABD7-1BACECCD8CEC@gmail.com>

Today I did a git pull of the master branch.
Is it possible that this patch is the cause of this error?

Error muted by safe_call: (treesit--font-lock-mark-ranges-to-fontify ((1 . 
8867)) #<treesit-parser for php>) signaled (wrong-type-argument treesit-node-p 
#<treesit-parser for php>)
Error during redisplay: (jit-lock-function 1) signaled (wrong-type-argument 
treesit-node-p #<treesit-parser for php>)

Vincenzo

In data domenica 30 giugno 2024 01:54:39 CEST, Yuan Fu ha scritto:
> > On Jun 25, 2024, at 11:04 PM, Yuan Fu <casouri@gmail.com> wrote:
> >> On Jun 24, 2024, at 12:46 AM, Yuan Fu <casouri@gmail.com> wrote:
> >>> On Jun 23, 2024, at 10:38 AM, Juri Linkov <juri@linkov.net> wrote:
> >>>>> Evaluating this expression causes a crash:
> >>>>> 
> >>>>> (progn
> >>>>> (find-file (expand-file-name "src/treesit.c" installation-directory))
> >>>>> (c-ts-mode)
> >>>>> (font-lock-ensure 63209 63387))
> >>>>> 
> >>>>> in latest master, but not in latest emacs-29 (only in 5-months old
> >>>>> emacs-29).
> >>>>> 
> >>>>> If this is not reproducible, I could provide more details.
> >>>>> 
> >>>>> libtree-sitter is at the latest version.
> >>>> 
> >>>> Hmm, I can’t reproduce with latest master and libtree-sitter. Maybe you
> >>>> can send me the exact commits that you used?
> >>>> 
> >>>> Here’s mine:
> >>>> 
> >>>> Emacs: 72f2b01e318
> >>>> Tree-sitter: 6ec478c1
> >>> 
> >>> Probably reproducibility depends on the content of the src/treesit.c
> >>> file.
> >>> Then the most reliable way to reproduce it is this:
> >>> 
> >>> 0. emacs -Q
> >>> 1. eval: (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
> >>> 2. C-x v L
> >>> 3. in the *vc-change-log* buffer move point to the commit 20af58d3a13
> >>> 4. type D
> >>> 5. crash caused by diff-font-lock-syntax fontification that uses treesit
> >>> 
> >>> The numbers in (font-lock-ensure 63209 63387) above were extracted
> >>> from diff hunk boundaries that might be different when the file was
> >>> edited.
> >> 
> >> I reproduce it once with the first set of commits you provided, but for
> >> some reason couldn’t reproduce it again. I’m sure it’s something wrong
> >> that I did. I’ll report back when I make progress. TBH it seems like
> >> something wrong with tree-sitter itself, but I’ll make sure to figure
> >> out what’s the problem exactly.
> >> 
> >> Yuan
> > 
> > Ok, I can reproduce it now. Looking into it…
> 
> 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.
> 
> Yuan












  parent reply	other threads:[~2024-06-30 19:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 16:33 bug#71681: 29.3.50; tree-sitter crash Juri Linkov
2024-06-22 23:55 ` Yuan Fu
2024-06-23  5:32   ` Eli Zaretskii
2024-06-23  6:46   ` Juri Linkov
2024-06-23 17:38   ` Juri Linkov
2024-06-24  7:46     ` Yuan Fu
2024-06-26  6:04       ` Yuan Fu
2024-06-29 23:54         ` Yuan Fu
2024-06-30 14:28           ` Vincenzo Pupillo
2024-06-30 16:15           ` Juri Linkov
2024-06-30 19:22           ` Vincenzo Pupillo [this message]
2024-07-01  5:37             ` Yuan Fu
2024-07-01 10:20               ` Vincenzo Pupillo
2024-07-01  6:49           ` Juri Linkov
2024-07-01  7:01             ` 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=2331247.vFx2qVVIhK@fedora \
    --to=v.pupillo@gmail.com \
    --cc=71681@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=juri@linkov.net \
    /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.