From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#73801: 31.0.50; project-try-vc sometimes set wrong cache project-vc-extra-root-markers Date: Tue, 29 Oct 2024 22:31:04 +0200 Message-ID: <9dc6f220-1748-4ed0-9c36-fffed80071f0@gutov.dev> References: <3b9816c7-bec3-4743-ad1a-49332c158099@gutov.dev> <1a2ab2c3-272a-41c8-af6f-6ed7348189df@gutov.dev> <86sesf58zz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11450"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: i@fuzy.me, 73801@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 29 21:32:40 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 1t5stJ-0002o0-SG for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Oct 2024 21:32:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5sss-0005gm-1W; Tue, 29 Oct 2024 16:32:10 -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 1t5ssk-0005fm-AB for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 16:32:06 -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 1t5ssk-0002uR-0R for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 16:32:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=akAVmJvsuqWRPxVpq5gh118UT4LlUw28SDbsAPJUz6E=; b=n+4Gr1c0fmjwauInIyipqD+kNzJKKvrJl42UFrBe/FrHKpiMfkIdavSMrX0Sc0PinTCgKKx1KfaqF9Nx/Z1LJeNAxiIZEVkW94a1XyTz2eBSqhNpgSt2giV6PsSAplc7w8rE/VFMBMcCUtka1FmhMJpVHuPGc8SLQRdBsisO7QPSItxqBEpZP93IHBBgG0Y8KhQxke6P0xX/fJtxf5pIUs8ILxsQSlsGmIgbIAOgi8662uy+HimrdtVgBJnGjt/urpa3HkE0XAOdxVauFKLHbE7P7r+WZgnlGVYPUrcdj94xwExVMYy4+K01Z2mZYozNZSek2oDcUt7BGPkWIAS6sw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t5ssj-0001EB-SH for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 16:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Oct 2024 20:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73801 X-GNU-PR-Package: emacs Original-Received: via spool by 73801-submit@debbugs.gnu.org id=B73801.17302338764675 (code B ref 73801); Tue, 29 Oct 2024 20:32:01 +0000 Original-Received: (at 73801) by debbugs.gnu.org; 29 Oct 2024 20:31:16 +0000 Original-Received: from localhost ([127.0.0.1]:58625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5ss0-0001DL-DG for submit@debbugs.gnu.org; Tue, 29 Oct 2024 16:31:16 -0400 Original-Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]:36047) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5srx-0001DD-7U for 73801@debbugs.gnu.org; Tue, 29 Oct 2024 16:31:14 -0400 Original-Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id 27D4711401E5; Tue, 29 Oct 2024 16:31:08 -0400 (EDT) Original-Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Tue, 29 Oct 2024 16:31:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1730233868; x=1730320268; bh=akAVmJvsuqWRPxVpq5gh118UT4LlUw28SDbsAPJUz6E=; b= FrKw+Fs0Dw67YhbXW4m471UU1VFaTbXhBkLsemKO1ccRwml5OFa3WWPJIhF8D5lh T+pKUTSwCIb8pv6pq05MgiSL9vjMFDjEZ3KTrkP7oDxlqwVCqwAtQZ5B5Dgsstjj l6l0/gasajjIbSQQWvfKwIx07rviwWg/GW2gW90fKLgf/vHDNN5DF+eteodJwL7B z6j7bTwFr2UxP+uCDpVo6z2CfGi6vFihBkoNnLjc7g1/0wm9VH7+ci/XorsenbjU b86kuyYOSeCYXfoRpW736zKE4rBUEybuLkNxSp2ub1K5hZa66w6zblJSq/dA1brC gykreD+XRQv3AMTcdvOgvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1730233868; x= 1730320268; bh=akAVmJvsuqWRPxVpq5gh118UT4LlUw28SDbsAPJUz6E=; b=V R0EvBchHQCBwniZrJigtELneOK42rvX/fpZfgaexG2Kcvbe7tZ2XIj0UBE5RcF7P tYc7Amnm7hisS9tz6y/8tM89k1PSOnkPl68k3+AKWO0nQU57KGjbbe3Mt290BDEI 4/C6FyZA/xB6D0tlDAohjOTZ7PzFisfvyn3x1+pBJtcvvWDhHHcljHg6RR2qglhU t66e4p9L6ouGUV4aJkCZFAE+gCmE5GZ18fL3RkoGjuD7TKpxnQRlqJ3gbP8ca3SM HeiWnxB7Sk9o5WjW3Fi1ReYYf/PlR6BoJyyUqw/HkdezEOCxpNmvuc5snSZUSbaf Bf1b8c5FQNvlQSoGa5Bog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdekuddgudeffecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddv jeenucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrd guvghvqeenucggtffrrghtthgvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeu fedtvddtveefhfdvveegudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthht ohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvghlihiisehgnhhurdhorh hgpdhrtghpthhtohepjeefkedtudesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphht thhopehisehfuhiihidrmhgv X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 29 Oct 2024 16:31:05 -0400 (EDT) Content-Language: en-US In-Reply-To: <86sesf58zz.fsf@gnu.org> 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:294536 Archived-At: On 29/10/2024 15:33, Eli Zaretskii wrote: >> Date: Tue, 29 Oct 2024 04:44:13 +0200 >> From: Dmitry Gutov >> Cc: Zhengyi Fu >> >> Since I see some changes added to the release branch still, >> >> On 28/10/2024 06:06, Dmitry Gutov wrote: >>> It would be nice to get either of the patches into Emacs 30, too, but it >>> might be a little late given where it is in the pretest. >> >> Eli, could we install either of the fixes for this bug to emacs-30 too? >> >> The one I installed on master is longer but should result in less I/O, >> while the patch by Zhengyi Fu is a one-liner, which might feel a little >> safer. > > I don't understand the implications of that one-line (nor, TBH, the > analysis of the original problem), so I'm not sure these changes are > safe. The original problem was due to project-try-vc being invoked recursively on a parent directory while a variable that affects its computation is bound to nil. The function itself (project-try-vc) memoizes its return value. As a result, any subsequent call to it with the same argument outside of the said binding could return wrong result. The first fix (one-liner) made sure that we're calling it with the same argument that is passed to the current call, ensuring that the cache will be rewritten after it returns. The second fix (mine) was to extract the value computation into a helper function, making the recursive call to not be memoized. > How do we know that catering to this corner case will not screw > other corner cases? Difficult to guarantee that 100%, but this specific case seems important enough, while at the same time we can infer that the change won't affect the majority scenario because the code is guarded by these conditions: (when root (when (not backend) ...