From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#60054: 29.0.60; Infinite loop when there are cyclic path in the parse tree Date: Sat, 17 Dec 2022 15:28:01 -0800 Message-ID: <23FFD6B5-D97E-4BEC-9027-EF47EBE89BD6@gmail.com> References: <0998189C-4A9E-4B27-A8A0-D208D11E9A39@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32051"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60054@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 18 00:29:28 2022 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 1p6gcQ-0008Cb-P3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Dec 2022 00:29:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6gc3-0005AH-UA; Sat, 17 Dec 2022 18:29:03 -0500 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 1p6gc2-0005A3-Si for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 18:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p6gc2-0003Yn-Gy for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 18:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p6gc2-0003GA-7P for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 18:29:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <0998189C-4A9E-4B27-A8A0-D208D11E9A39@gmail.com> Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Dec 2022 23:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60054 X-GNU-PR-Package: emacs Original-Received: via spool by 60054-submit@debbugs.gnu.org id=B60054.167131969112513 (code B ref 60054); Sat, 17 Dec 2022 23:29:02 +0000 Original-Received: (at 60054) by debbugs.gnu.org; 17 Dec 2022 23:28:11 +0000 Original-Received: from localhost ([127.0.0.1]:58567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6gbC-0003Fl-WC for submit@debbugs.gnu.org; Sat, 17 Dec 2022 18:28:11 -0500 Original-Received: from mail-pj1-f51.google.com ([209.85.216.51]:37527) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6gbB-0003Ff-3A for 60054@debbugs.gnu.org; Sat, 17 Dec 2022 18:28:09 -0500 Original-Received: by mail-pj1-f51.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so9589695pjj.2 for <60054@debbugs.gnu.org>; Sat, 17 Dec 2022 15:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=IYL2ES70ySK/T2ONlA+YdHgkmaDazH3+zObfh6h1M3g=; b=nGmmB0WhSeac47x2n12/6QycdyDq2rZpAsVIhMEeQXPXxso6V/KAouOuC9C2iJ6Im/ 84ACLMzJfW0ccGBoZkLrJHrYajjnMOfJoH0C70Rb1vnSPHfXuVnhZj9hB5yrFnN8OywI ykBlVryXLPObZJmI6KGtiQGEJRGj2MwEys8MEqwq0107/GSm2iP6oSWW17jnpwdp9hgp p8dXo/DSRbZRme2WQno8dZX17Ciga2b84qM498s4tiwhyIUaM1l1nNnp6VFY6ZzcBFFx n8ZZuzlffX6B7dNGRxSEcUie7PbWXuq0t7MQowVz7bPUU3lE8o4QgdA32L1KMby1J1Uq 5BbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IYL2ES70ySK/T2ONlA+YdHgkmaDazH3+zObfh6h1M3g=; b=HdPilcrcmLlFOhboTyEL9p3mhjmPL7tRV5G/hgufNg8tbB9uvDkfnIgWLKj2xfFSOS /4ephuKxTpzHtEMMqzfX2PhOJz2/ESM/abgRYyxYEYJEjrK/l/AJAVmNjV/qzZ6fnvU0 qSdaSvihX7SaAA5UkliKHk/LMwIK4AtpZYGWJsglS2FeDIDnfJPS9jyvMY3xQC//ofC7 eamwRH4/SFzKJkXG+9+X9NqpP8D2cuQy11kbbwPPoDZNpt5La4bNeX/TZPLONzdcw/h0 m0vkQmEh4UBb9SEBmNrK4+r/jTEcWgmgU1RkuBKZBdawhlo9lG1fx12XnL2S1abw79Ti jsSQ== X-Gm-Message-State: ANoB5pm5n+jlFAYaXkOCWiUkeGwnG51m6fQfm5VUJB182SE+xLGSR5e6 tu2RuERf2KIqLwK4nYgs9ek/BZjSjSo= X-Google-Smtp-Source: AA0mqf6G+W2ypPXWVKQR2DN9ZCiQOUz9uHKruGxXBwoq0UkYa6oQjYPKw6XDK0xufIeZqasqzvi2vg== X-Received: by 2002:a17:902:6bcc:b0:188:5b7d:738a with SMTP id m12-20020a1709026bcc00b001885b7d738amr36469062plt.29.1671319683211; Sat, 17 Dec 2022 15:28:03 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id z9-20020a1709027e8900b001910b21fe90sm2434824pla.210.2022.12.17.15.28.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Dec 2022 15:28:02 -0800 (PST) X-Mailer: Apple Mail (2.3696.120.41.1.1) 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:251317 Archived-At: Yuan Fu writes: > Eli Zaretskii writes: > >>> From: Yuan Fu >>> Date: Wed, 14 Dec 2022 12:27:58 -0800 >>> Cc: 60054@debbugs.gnu.org >>>=20 >>> >> https://github.com/tree-sitter/tree-sitter-c/issues/119 >>> >>=20 >>> >> So far, I=E2=80=99ve only observed this in that specific edge = case. >>> >=20 >>> > We should have protection against that, which should be easy, = right? >>>=20 >>> Just to make sure, we want to use something like slow-fast pointers, >>> where we have two pointers, and one goes twice as fast, right? >>> That=E2=80=99s the one I was taught in school :-) >> >> No, I mean protect us from inflooping by checking that the parent of = a >> node is not the node itself. > > In this particular case, it is the siblings=E2=80=99 parent that = equals to the > node. Ie, node->sibling->parent =3D node. If your intention is to = protect > us from this particular case, switching to use cursors will avoid this > bug. Ok, I made the change to use cursor API with tests. Hopefully this is the last time we need to change treesit.c before release. The node->sibling->parent =3D node cyclic path should be fixed by this = change, do you still want checks for it? Yuan