From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73801: 31.0.50; project-try-vc sometimes set wrong cache project-vc-extra-root-markers Date: Thu, 31 Oct 2024 12:06:31 +0200 Message-ID: <86r07w37tk.fsf@gnu.org> References: <3b9816c7-bec3-4743-ad1a-49332c158099@gutov.dev> <1a2ab2c3-272a-41c8-af6f-6ed7348189df@gutov.dev> <86sesf58zz.fsf@gnu.org> <9dc6f220-1748-4ed0-9c36-fffed80071f0@gutov.dev> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33365"; mail-complaints-to="usenet@ciao.gmane.io" Cc: i@fuzy.me, 73801@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 31 11:07:28 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 1t6S5M-0008QG-9j for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 31 Oct 2024 11:07:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6S52-00080W-Rn; Thu, 31 Oct 2024 06:07:04 -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 1t6S50-000809-Kj for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:07:02 -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 1t6S50-0003vE-9x for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:07:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=VQ9msztdjgpmEGlpzum3S92zEwBsBgMgFi7GfL3kL6c=; b=ZGkDr0d7HJxptSaaEIpUJAgsKqaR9BKBYx1A65uko/8Pnos21obbitW+uGZU1YaSzDTbG8cYCxFRceKwCqPgitBhoPA/WOliJyqsqRd4erggiQM+L/Eyvf5XrFKByQ1co5/IIFz8rVzv8EL6S50SxEAW5IBAYvCe30MQ034uxqIXOR/UrAnjDg/FM7mQykkh74iO/EiQPi/m04YRLAeHynRsHKGUaZia28zQbn9h3kivpZh7dLZemzwjWWCa5u/b21MNWl5js6jf12nqKv522ceu4WQ/yBfiCmb83yukYby4GyLwAKUioe88cnfJP36AwivXO71pQkicyuXCbhPbCA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t6S50-0001xf-4T for bug-gnu-emacs@gnu.org; Thu, 31 Oct 2024 06:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Oct 2024 10:07:02 +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.17303692037525 (code B ref 73801); Thu, 31 Oct 2024 10:07:02 +0000 Original-Received: (at 73801) by debbugs.gnu.org; 31 Oct 2024 10:06:43 +0000 Original-Received: from localhost ([127.0.0.1]:41358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6S4g-0001xJ-RV for submit@debbugs.gnu.org; Thu, 31 Oct 2024 06:06:43 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t6S4e-0001xA-Dg for 73801@debbugs.gnu.org; Thu, 31 Oct 2024 06:06:41 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6S4Y-0003tp-2X; Thu, 31 Oct 2024 06:06:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=VQ9msztdjgpmEGlpzum3S92zEwBsBgMgFi7GfL3kL6c=; b=VmlM6v0fjVcT 7Su4xTkMZoJkO/uyzDfSR58ejNpJmANqGYVQQm6xPvoIzNFlgsJp0A1fRgU5kwBPr/lEr8DYn0f2h O2Bm/mvFhruUHRiRKNNu0FP0Pfx/sbvutNhlIDkCev9LXCWhGsv3u5JEa9IremmFdpdt/R1DlvHw7 WiVvV7hmMtfFyS3eQrdoGQj9Xr1WJ5W0ek5vaX1TuR+cVMj5V/bsJ+Sfl3zzpM5BswNRfUNicdIDI R7M9LSxaJXrPWdLA7vi8iUgpeGk81OBq9YmQnL2J1u6yWfMRJ6Oncqewy4y+/wgdL6kA2o5fzjVuY 8Dae7t7qjUWHGT83SHfe5g==; In-Reply-To: <9dc6f220-1748-4ed0-9c36-fffed80071f0@gutov.dev> (message from Dmitry Gutov on Tue, 29 Oct 2024 22:31:04 +0200) 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:294605 Archived-At: > Date: Tue, 29 Oct 2024 22:31:04 +0200 > Cc: 73801@debbugs.gnu.org, i@fuzy.me > From: Dmitry Gutov > > 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) > ... FWIW, I have a bad feeling about this, but if you are confident, feel free to backport.