From unknown Sat Jun 21 05:08:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75779: persist-defvar symbol bound before definition, causing data loss Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Jan 2025 07:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75779 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 75779@debbugs.gnu.org Cc: Adam Porter X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173761841723958 (code B ref -1); Thu, 23 Jan 2025 07:47:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jan 2025 07:46:57 +0000 Received: from localhost ([127.0.0.1]:38992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tarvU-0006EL-Kl for submit@debbugs.gnu.org; Thu, 23 Jan 2025 02:46:57 -0500 Received: from lists.gnu.org ([2001:470:142::17]:42192) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tarvR-0006E5-Ou for submit@debbugs.gnu.org; Thu, 23 Jan 2025 02:46:54 -0500 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 1tarvM-0007IK-9U for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2025 02:46:48 -0500 Received: from out-181.mta0.migadu.com ([91.218.175.181]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tarvI-0003Px-CG for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2025 02:46:48 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1737618396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=+/2fyyYJuw+tzHDJNs1wtHXCt1VxEBcry6ME6GEygmw=; b=BTBbYa3vl9lmxqS1QMX/9m76zkYGYw+rPsNityyHO5bxofK0oBddkCqZaQYQpFO5Xm0gmY 5APoGTMMhQGQnkwvScb+4V/CWLP1w5lsQYHdTm98IhISkQgd8D736Rnlr1/QgsPovm/SoA u4CfzstMbFCNZFOsq8J3IPiag4/saAU= From: Joseph Turner Date: Wed, 22 Jan 2025 23:46:32 -0800 Message-ID: <87plkeotuv.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.181; envelope-from=joseph@breatheoutbreathe.in; helo=out-181.mta0.migadu.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain 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 <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. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=test-persist-issue.el Content-Transfer-Encoding: quoted-printable ;;; test-persist-issue.el -*- lexical-binding: t; -*- ;; Version: 0.1-pre ;; Package-Requires: ((persist "0.6")) (require 'persist) (persist-defvar test-persist-issue nil "Docstring.") (provide 'test-persist-issue) --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=test-persist-issue-other-file.el Content-Transfer-Encoding: quoted-printable ;;; test-persist-issue-other-file.el -*- lexical-binding: t; -*- (require 'test-persist-issue) test-persist-issue (provide 'test-persist-issue-other-file) --=-=-=-- From unknown Sat Jun 21 05:08:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75779: persist-defvar symbol bound before definition, causing data loss Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Feb 2025 00:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75779 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 75779@debbugs.gnu.org Cc: Adam Porter Received: via spool by 75779-submit@debbugs.gnu.org id=B75779.17385413585522 (code B ref 75779); Mon, 03 Feb 2025 00:10:02 +0000 Received: (at 75779) by debbugs.gnu.org; 3 Feb 2025 00:09:18 +0000 Received: from localhost ([127.0.0.1]:36787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tek1d-0001Qy-TJ for submit@debbugs.gnu.org; Sun, 02 Feb 2025 19:09:18 -0500 Received: from out-183.mta0.migadu.com ([2001:41d0:1004:224b::b7]:52448) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tek1a-0001QX-KN for 75779@debbugs.gnu.org; Sun, 02 Feb 2025 19:09:16 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1738541343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xGZnZMLiNIEk6rib8Zhi03VFb2Tg3QK2ZuBvddBXt3A=; b=UBmkud1zGFR6o05ZB2QPa63rj+77IeJ4JFydkpiAFvLeXdjl2ANUruorgS6ZA5o3uJjq6V gV0F8zb6yE49Eqrn7totHdLH3mLwKpdQsxNciDirQY5IsvwLz2tltX+a3NJR+jmfP1B0Qz 54n+VbhZix6kg4XUAvSdyjqTLgMik6s= From: Joseph Turner In-Reply-To: <87plkeotuv.fsf@breatheoutbreathe.in> (Joseph Turner via's message of "Wed, 22 Jan 2025 23:46:32 -0800") References: <87plkeotuv.fsf@breatheoutbreathe.in> Date: Sun, 02 Feb 2025 16:08:53 -0800 Message-ID: <878qqnvqi2.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Ping Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > 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 < (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. > > [2. application/emacs-lisp; test-persist-issue.el]... > > [3. application/emacs-lisp; test-persist-issue-other-file.el]...