GNU bug report logs - #75780
persist-defvar symbol bound before definition, causing data loss

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> breatheoutbreathe.in>

Date: Thu, 23 Jan 2025 07:48:01 UTC

Severity: normal

Done: Joseph Turner <joseph <at> breatheoutbreathe.in>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75780 in the body.
You can then email your comments to 75780 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#75780; Package emacs. (Thu, 23 Jan 2025 07:48:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joseph Turner <joseph <at> breatheoutbreathe.in>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 23 Jan 2025 07:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: bug-gnu-emacs <at> gnu.org
Cc: Adam Porter <adam <at> alphapapa.net>
Subject: persist-defvar symbol bound before definition, causing data loss
Date: Wed, 22 Jan 2025 23:47:06 -0800
[Message part 1 (text/plain, inline)]
This bug report was previously submitted as bug#75684, but it appears to
have been lost by the mailing list.  Here it is again:

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 Github report.

Thank you!

Joseph

P.S. The linked git.sr.ht 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:

[test-persist-issue.el (application/emacs-lisp, attachment)]
[test-persist-issue-other-file.el (application/emacs-lisp, attachment)]

Reply sent to Joseph Turner <joseph <at> breatheoutbreathe.in>:
You have taken responsibility. (Thu, 23 Jan 2025 07:57:02 GMT) Full text and rfc822 format available.

Notification sent to Joseph Turner <joseph <at> breatheoutbreathe.in>:
bug acknowledged by developer. (Thu, 23 Jan 2025 07:57:02 GMT) Full text and rfc822 format available.

Message #10 received at 75780-done <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: help-debbugs <at> gnu.org (GNU bug Tracking System)
Cc: 75780-done <at> debbugs.gnu.org
Subject: Re: bug#75780: Acknowledgement (persist-defvar symbol bound before
 definition, causing data loss)
Date: Wed, 22 Jan 2025 23:56:04 -0800
Duplicate of bug#75779.  Sorry for the noise.

help-debbugs <at> gnu.org (GNU bug Tracking System) writes:

> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
>  bug-gnu-emacs <at> gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 75780 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs <at> gnu.org unless you wish
> to report a problem with the Bug-tracking system.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 20 Feb 2025 12:24:16 GMT) Full text and rfc822 format available.

This bug report was last modified 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.