From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mickey Petersen Newsgroups: gmane.emacs.bugs Subject: bug#60237: 30.0.50; tree sitter core dumps when I edebug view a node Date: Mon, 27 Feb 2023 08:22:04 +0000 Organization: Mastering Emacs Message-ID: <875ybnwm2r.fsf@masteringemacs.org> References: <9FCDA5B7-D216-45B1-8051-35B05633BEFB@gmail.com> <83sfeukwsb.fsf@gnu.org> <574817C4-3FD8-43EA-B53C-B2BCB60A6D0A@gmail.com> <87a610wyod.fsf@masteringemacs.org> Mime-Version: 1.0 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="37204"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e @VERSION@; emacs 30.0.50 Cc: Po Lu , Eli Zaretskii , 60237@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 27 09:31:59 2023 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 1pWYvO-0009QV-Dp for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Feb 2023 09:31:58 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWYqs-00043u-MD; Mon, 27 Feb 2023 03:27:18 -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 1pWYqc-0003id-OC for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 03:27:07 -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 1pWYqc-0002hn-EC for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 03:27:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pWYqb-00047I-WF for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 03:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mickey Petersen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Feb 2023 08:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60237 X-GNU-PR-Package: emacs Original-Received: via spool by 60237-submit@debbugs.gnu.org id=B60237.167748641315808 (code B ref 60237); Mon, 27 Feb 2023 08:27:01 +0000 Original-Received: (at 60237) by debbugs.gnu.org; 27 Feb 2023 08:26:53 +0000 Original-Received: from localhost ([127.0.0.1]:45820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWYqT-00046t-4x for submit@debbugs.gnu.org; Mon, 27 Feb 2023 03:26:53 -0500 Original-Received: from mail-cwlgbr01on2126.outbound.protection.outlook.com ([40.107.11.126]:28241 helo=GBR01-CWL-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWYqN-00046b-Vg for 60237@debbugs.gnu.org; Mon, 27 Feb 2023 03:26:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=frVghmeB5aWH4i4j30YPueo/cpmoT7NPb+VhdOhcoJYtwMNU8aglx29FGouqwqSPOSupQ/JCIWkR754cdfOxrAv4s2cg3HccxAO2s1SdUrX3g3BdUZSvsPhW2gfaTArvifRzSgTKb3WzT/rulgPYkdrTHqBXXebsFfB7bNv934pqMnzm4X04gFHiSq3LjllycztIKIEbxPpdMS2yGfPIgbu+zub2VbPUwyrMEX0uO27q8eOOLZZhPEBZdM84bl7aX4CSj/vqYgdjixdYJ3pVI1qbz21N3Hm/JEjtLPtrGLlu3qNSCqgx2hpcAQ2ld+Uy6ZR1kwNn8+4lT8d1GH1inw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fTpMs1SeDyEFWXqdKAMOvcpKlK+f61wjdXHKXgu6+Y8=; b=GUWa1n1DePA1q8nN/OgK+oht8T1Ep4oJSDAF/SrI2hL1j+kM5+pjZ6+h/LMhrjzRY3SFfpolkcYqV2SjHMszjmUd8MfqG7PB6oKBBf5bxY02em3y+ZNO4sH0F9FWWaISohanStdmVWaxo7mLAZr5pIOrHZb3neR4GYyhxeFx3FnJdN5NSC7cImK3/R77sHTNZN5fCHm2JlVxcrObYZD8fPV1a98Ql4WBG0Zrq42L71TsWqWSUlFwPTJnsN/b7VMcwmMeOqNzmYDoqei1PC+/P+WqE2sXlImo4Ck+8rWkQpSd7yW5GOlqWOYvtfKTOdC3bcZAUUWU8ImqUNw5F4Qz6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 178.79.136.144) smtp.rcpttodomain=debbugs.gnu.org smtp.mailfrom=masteringemacs.org; dmarc=pass (p=none sp=none pct=100) action=none header.from=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semantical.onmicrosoft.com; s=selector1-semantical-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fTpMs1SeDyEFWXqdKAMOvcpKlK+f61wjdXHKXgu6+Y8=; b=e6eiHRGXxdxw+Sz+I3ImScX7vOSjtmkyFu+odMfjcYTr3+N2WGec7egQ4q34G3wlBxZrRGH1tCF6GBo9Eo5Gj3LiqmAKygMaRhl7XKYJ7DCOJapeLsoaCM0m1P29MugeiPBAhCboHvHk4itM48ov+7q3VNZT6HeIdg5ftceNqRo= Original-Received: from LO3P123CA0029.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:388::19) by LO0P265MB5166.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:282::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 08:26:41 +0000 Original-Received: from CWLGBR01FT021.eop-gbr01.prod.protection.outlook.com (2603:10a6:600:388::4) by LO3P123CA0029.outlook.office365.com (2603:10a6:600:388::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29 via Frontend Transport; Mon, 27 Feb 2023 08:26:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 178.79.136.144) smtp.mailfrom=masteringemacs.org; dkim=pass (signature was verified) header.d=masteringemacs.org;dmarc=pass action=none header.from=masteringemacs.org; Received-SPF: Pass (protection.outlook.com: domain of masteringemacs.org designates 178.79.136.144 as permitted sender) receiver=protection.outlook.com; client-ip=178.79.136.144; helo=semantical.co.uk; pr=C Original-Received: from semantical.co.uk (178.79.136.144) by CWLGBR01FT021.mail.protection.outlook.com (10.152.40.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Mon, 27 Feb 2023 08:26:39 +0000 Original-Received: by semantical.co.uk (Postfix, from userid 5001) id 34080114002; Mon, 27 Feb 2023 08:26:39 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=masteringemacs.org; s=masteringemacs.org; t=1677486399; bh=AozE48fjbkx6bd3Dz/v8NGvAr5uf4oVBGaGjEr1988U=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=fSUNF0qPHG6QPIolSCOzYQWu8vqjfJjj5uUVGcLqNUOngf6nIFGmL8BzjO1HRgZbF OKes38JP38Vvk+lzNWp+eNBTDgtpH3y/hP5YsCxMiCdaEAxSwIMiw0rmkbVDtbrfA9 /BhnxVMWyL7uXFYHH9oBFh58eIlRg0o2v4yE+uj4= In-reply-to: X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CWLGBR01FT021:EE_|LO0P265MB5166:EE_ X-MS-Office365-Filtering-Correlation-Id: 20be34b6-2ab0-4827-7859-08db189c594f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +Rn4LjjOteXlcFo8GhJZJFqhJ/v1JnvPv++XgdpdG5EESrYivLYLG+i5bvWMzBO45UaUBgWlzodOtvlTYxIAQ3K182HsmiSzz2cLnwAOr3BL+80ujZl+eVMMDOgrxBtUXcd8IZizi5PvIxtZXVtcP8eTsZHTV1iSmTPKdPyLGeTKigPMpt9BWe93IMnLeRK+LSBKUkYRf9fHGLk3Tu0kxs32mFhas1AZ7/mIUApK7wyBMw14Tr7oaZ6L9qIim7d1pT5+OkVsQA9XiOsV/D2LZOcyAKEKV5TUTqzQbf5lk5kFjfWztM3qIdJxlNMw2ejhFYF459ol4LBhj0zDpoSCukR/+1g0VGUKg3d00bWalsmjFrFqP5U8qrpCJ9z3X/Hcz9E2D68q8iTV5Mt773l8vjI5OiqUdH5bZy0OKM/ZEJ64AvVOuPsLuRZc34sccZafxhITNN3nhY/r3a/G59C61f24Eq1eWW0tPAkYT+dlb9R0hiWmvebHMHEdUnJdgQRKTH2IFHFAtGVoJ40l868RHUO4FEbq5cfBIgs2ejh4s+MO1HAnOx0ShTtzJelukThBrtMOVWlxWPmw3Epo4IZZyzf2IVMHeC+kOE3Ec9uB0tdjQDbMxUOg6dINDe9EWeF3DoG6Z8ruygRevBt96hcKkAJELj1I2f1wVoTM9gMQJZYu1nTh0M9L7kbCYIJ5xqpULVnWpomSeZq0XAhgxunKX8bswcMXbswk8ZBjDS2SYOY5dtQt4R5AUldsjHPm5 IUq X-Forefront-Antispam-Report: CIP:178.79.136.144; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:semantical.co.uk; PTR:semantical.co.uk; CAT:NONE; SFS:(13230025)(39830400003)(396003)(376002)(346002)(136003)(451199018)(36840700001)(46966006)(41300700001)(83380400001)(70586007)(70206006)(4326008)(8676002)(7636003)(36860700001)(7596003)(36756003)(2906002)(82310400005)(86362001)(40480700001)(356005)(6862004)(5660300002)(8936002)(47076005)(2616005)(336012)(36916002)(478600001)(107886003)(42186006)(6266002)(54906003)(316002)(6666004)(186003)(53546011)(26005)(38230200001)(14776008)(79816003); DIR:OUT; SFP:1102; X-OriginatorOrg: masteringemacs.org X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 08:26:39.4933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20be34b6-2ab0-4827-7859-08db189c594f X-MS-Exchange-CrossTenant-Id: a4e27e3d-bab0-45e8-8942-e64cf9fbd34f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a4e27e3d-bab0-45e8-8942-e64cf9fbd34f; Ip=[178.79.136.144]; Helo=[semantical.co.uk] X-MS-Exchange-CrossTenant-AuthSource: CWLGBR01FT021.eop-gbr01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO0P265MB5166 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:256852 Archived-At: Yuan Fu writes: >> On Feb 26, 2023, at 1:41 AM, Mickey Petersen = wrote: >> >> >> Yuan Fu writes: >> >>>> GC has historically never called xmalloc, so the profiler will >>>> likely >>>> crash upon growing the mark stack as well. I guess another >>>> important >>>> question is why ts_delete_parser is calling xmalloc. >>>> >>> >>>> As you see, when we call ts_tree_delete, it calls >>>> ts_subtree_release, >>>> which in turn calls malloc (redirected into our xmalloc). Is this >>>> expected? Can you look in the tree-sitter sources and verify that >>>> this is OK? >>> >>> I had a look, and it seems legit. In tree-sitter, a TSTree (or more >>> precisely, a Subtree) is just some inlined data plus a refcounted >>> pointer to the complete data. This way multiple trees share common >>> subtrees/nodes. Eg, when incrementally parsing, you pass in an old >>> tree and get a new tree, these two trees will share the unchanged part >>> of the tree. >> >> Would that mean we could possibly preserve node instances -- either >> the real TS ones, or an Emacs-created facsimile -- between >> incremental parsing? That would be useful for refactoring. > > What kind of exact interface (function) do you want? The > treesit-node-outdated error is solely Emacs=E2=80=99s product, tree-sitter > itself doesn=E2=80=99t mark a node outdated. It is possible for Emacs to = not > delete the old tree and give it to you, or allow you to access > information of an outdated node. OK, so let me explain: Touching the buffer for any reason invalidates the whole tree; that's not good. It's not good, because a lot of the information may still be useful and viable. Outdating the node is not a bad idea as it avoids a lot of 'traps' around accidental modifications that can corrupt things without the developer's knowledge. I'd like to be able to access all the information possible; perhaps behind a flag variable like `treesit-allow-outdated-node-access'. What I'm really mostly interested in is: - How well the node references handle changes in byte positions in TS. - Does changing something at X shift (like a `point-marker`) everything below it? Does an outdated node correctly reference its new location and state, such as changes to children or its position in the tree? Right now, Combobulate can make a proxy node, which essentially captures the basics of a live node and stores it in a defstruct. That way I can at least retain the start/end, type, text, etc. of a node and still do light refactoring without contorting myself to do things in a particular order, which is not always possible (like delaying editing to the very end.)