bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13860: 24.2; dir-locals-directory-cache unreliable in one rare case


From: Lars Ingebrigtsen
Subject: bug#13860: 24.2; dir-locals-directory-cache unreliable in one rare case
Date: Wed, 14 Aug 2019 23:18:44 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Johan Claesson <address@hidden> writes:

> Maybe i have misunderstood something but i find the cache
> mechanism for directory local variables unreliable in one rare
> case.  If first .dir-locals.el is read and a binding say foo = 1 is
> inserted in the dir-locals-directory-cache.  And then foo = 2 is
> written in the same second.  Now next time the dir locals the old
> binding foo = 1 will be returned.  The cache entry is considered
> valid when it should not.  
>
> Of course it is unlikely that a user is typing so fast that they
> trigger this :).  But it can be triggered from Lisp.  I found out
> when playing with a ert test case that was tampering with a dir
> local.  

(I'm going through old bug reports that have unfortunately gotten no
responses yet.)

> Here is a recipe for this:
>
> (defvar foo nil)
> (put 'foo 'safe-local-variable 'numberp)
> (let ((dir (make-temp-file "cache-test" t)))
>   ;; Create .dir-locals.el with foo = 1.
>   (with-temp-buffer
>     (cd dir)
>     (add-dir-local-variable nil 'foo 1)
>     (save-buffer)
>     (kill-buffer))
>   ;; Read it into dir-locals-directory-cache
>   ;; and save .dir-locals.el with foo = 2.
>   (with-temp-buffer
>     (cd dir)
>     (make-local-variable 'foo)
>     (hack-dir-local-variables-non-file-buffer)
>     (add-dir-local-variable nil 'foo 2)
>     (save-buffer)
>     (kill-buffer))
>   ;; Read it back again.
>   ;; It should be 2 at this point but is 1 most of the times. 
>   ;; (At the rare occasion that seconds increase
>   ;; between the two add-dir-local-variable it returns 1).
>   (with-temp-buffer
>     (cd dir)
>     (make-local-variable 'foo)
>     (hack-dir-local-variables-non-file-buffer)
>     (delete-file dir-locals-file)
>     (delete-directory dir) 
>     foo))

I'm unable to reproduce this problem in Emacs 27, but perhaps this could
be a problem if the file system doesn't have sub-second resolution?  Are
there such file systems still in use (I mean, for something where'd you
store file with file-local variables)?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]