Subject: bug#75684: closed (Re: bug#75684: missing from mailing list archives)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 23 Jan 2025 07:43:02 +0000

Your bug report

#75684: persist-defvar symbol bound before definition, causing data loss

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
75684: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75684
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#75684: missing from mailing list archives
From: Joseph Turner <[email-masked]>
To: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]>
Cc: [email-masked]
Date: Wed, 22 Jan 2025 23:42:25 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> writes:

> Three days ago, on 2025-01-19, I submitted bug report #75684.  I received
> the acknowledgment email, but I don't see the bug report in the mailing
> list archive.  I know there have been some issues with some of the FSF
> infrastructure over the past few days, so I wonder if my bug report was
> somehow lost (and maybe other bug reports too?).
>
> Thank you!
>
> Joseph

Hmm...  Now I see this message on the mailing list archives as if it
were bug#75684.

I'll just re-submit my bug report again.

Thanks!

Joseph

Subject: persist-defvar symbol bound before definition, causing data loss
From: Joseph Turner <[email-masked]>
To: [email-masked]
Cc: Adam Porter <[email-masked]>
Date: Sun, 19 Jan 2025 23:48:52 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Variables defined with persist-defvar which have persisted values are
sometimes bound to their persisted values before the package is loaded.
persist-defvar then incorrectly sets the symbol's persist-default
property to its persisted value, which then causes the persist value to
sometimes be deleted.

The bug in the wild: https://github.com/alphapapa/activities.el/issues/109

I am able to reproduce this issue on Emacs 29.4:

--8<---------------cut here---------------start------------->8---
rm -rf /tmp/test-persist-issue/
mkdir /tmp/test-persist-issue
cat > /tmp/test-persist-issue/init.el <<EOF
(package-initialize)

(unless (package-installed-p 'test-persist-issue)
  (package-vc-install "https://git.sr.ht/~breatheoutbreathein/test-persist-issue"))
EOF

emacs --init-directory=/tmp/test-persist-issue/
--8<---------------cut here---------------end--------------->8---

Wait for Emacs to install test-persist-issue.el and persist.el, then:

--8<---------------cut here---------------start------------->8---
(progn
  (require 'test-persist-issue)
  (setf test-persist-issue 'foo)
  (persist-save 'test-persist-issue)
  (kill-emacs))
--8<---------------cut here---------------end--------------->8---

/tmp/test-persist-issue/persist/test-persist-issue now exists as
expected.  Now run:

--8<---------------cut here---------------start------------->8---
rm -rf /tmp/test-persist-issue/elpa/
emacs --init-directory=/tmp/test-persist-issue/
--8<---------------cut here---------------end--------------->8---

Wait for installation again, then evaluate:

--8<---------------cut here---------------start------------->8---
(progn
  ;; (persist-default 'test-persist-issue)  ;; foo (should be nil)
  (persist-save 'test-persist-issue))
--8<---------------cut here---------------end--------------->8---

The second time Emacs is opened, just before the call to persist-defvar
in activities.el, the test-persist-issue variable is already bound to
the persisted value, which results in the persisted value being
incorrectly set as the default.

Why is the persist variable bound before the persist-defvar form?

This example uses package-vc for the sake of reliable bug reproduction,
but the issue also exists with package.el, as in the original report.

Thank you!

Joseph

P.S. The linked git repo contains two files, both of which appear to be
necessary to reproduce the issue.  For the sake of future bug
reproduction, I have attached both files to this email.