From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#71681: 29.3.50; tree-sitter crash Date: Sun, 30 Jun 2024 19:15:28 +0300 Organization: LINKOV.NET Message-ID: <86cynyrixj.fsf@mail.linkov.net> References: <86h6dny3om.fsf@mail.linkov.net> <9D0E4C93-9CCC-4C0E-BDF7-CB6F09132C23@gmail.com> <86o77rpnjz.fsf@mail.linkov.net> <74F62063-1C20-4257-92BA-F2CF02B9A588@gmail.com> <25A37A53-DD48-4E34-ABD7-1BACECCD8CEC@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30807"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: 71681@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 30 18:39:27 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sNxaI-0007sd-PW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Jun 2024 18:39:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNxZz-00029R-CL; Sun, 30 Jun 2024 12:39:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNxZv-00026D-EX for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 12:39:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNxZu-0004kh-KU for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 12:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sNxZu-0003qs-Jc for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 12:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jun 2024 16:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71681 X-GNU-PR-Package: emacs Original-Received: via spool by 71681-submit@debbugs.gnu.org id=B71681.171976550414742 (code B ref 71681); Sun, 30 Jun 2024 16:39:02 +0000 Original-Received: (at 71681) by debbugs.gnu.org; 30 Jun 2024 16:38:24 +0000 Original-Received: from localhost ([127.0.0.1]:58838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNxZH-0003pi-MP for submit@debbugs.gnu.org; Sun, 30 Jun 2024 12:38:23 -0400 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]:39389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNxZF-0003pS-MM for 71681@debbugs.gnu.org; Sun, 30 Jun 2024 12:38:22 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id E44EC40002; Sun, 30 Jun 2024 16:37:54 +0000 (UTC) In-Reply-To: <25A37A53-DD48-4E34-ABD7-1BACECCD8CEC@gmail.com> (Yuan Fu's message of "Sat, 29 Jun 2024 16:54:39 -0700") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288208 Archived-At: > 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.