From: Noam Postavsky <npostavs@gmail.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: jwiegley@gmail.com, 29220@debbugs.gnu.org,
monnier@iro.umontreal.ca,
"Pierre Téchoueyres" <pierre.techoueyres@free.fr>
Subject: bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object.
Date: Mon, 27 May 2019 19:36:04 -0400 [thread overview]
Message-ID: <87v9xv79nf.fsf@gmail.com> (raw)
In-Reply-To: <87h8q4uc8x.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 25 Feb 2018 10:59:10 -0800")
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>> Bah, this is annoyingly difficult -- thank you for trying it out. I
>>> suppose one terrible heuristic would be if the errors were different
>>> between emacs-25, emacs-26, and fix/eieio-persistent. Would you mind
>>> sending me the error output, in case anything jumps out at me?
>>>
>> Hope this could help you.
>
> Thanks. They all end in "Corrupt object on disk", which is an
> eieio-persist problem. I'll keep working on this.
So, I think it would be nice to have this fixed for 26.3. It sounds
like the fix you're working on is too risky to have on a release branch
regardless of its current status, so here's a patch which makes eieio
objects use symbols as type tags, when eieio-backward-compatibility is
non-nil. Folks who want the record-with-circular-references as type
tags can still get that by setting eieio-backward-compatibility to nil.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4273 bytes --]
From f6cc4509073da4ff23a4227d48b33108b1e96828 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Mon, 27 May 2019 19:05:56 -0400
Subject: [PATCH] Use plain symbols for eieio type descriptors (Bug#29220)
Since Emacs 26, eieio objects use a class record (with circular
references) as the type descriptor of the object record. This causes
problems when reading back an object from a string, because the class
record is not `eq' to the canonical one (which means that read objects
don't satisfy the foo-p predicate).
* lisp/emacs-lisp/eieio.el (make-instance): As a (partial) fix, set
the record's type descriptor to a plain symbol for the type descriptor
when eieio-backward-compatibility is non-nil (the default).
* lisp/emacs-lisp/eieio-core.el (eieio--object-class): Call
eieio--class-object on the type tag when eieio-backward-compatibility
is non-nil.
(eieio-object-p): Use eieio--object-class instead of
eieio--object-class-tag.
* test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
(eieio-test-persist-hash-and-vector)
(eieio-test-persist-interior-lists): `persist-test-save-and-compare'
no longer throws an error.
---
lisp/emacs-lisp/eieio-core.el | 11 +++++++----
lisp/emacs-lisp/eieio.el | 3 +++
test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el | 6 ++----
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index f879a3999f..4d55ed6e1d 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -117,9 +117,6 @@ (eval-and-compile
(defsubst eieio--object-class-tag (obj)
(aref obj 0))
-(defsubst eieio--object-class (obj)
- (eieio--object-class-tag obj))
-
\f
;;; Important macros used internally in eieio.
@@ -132,6 +129,12 @@ (defsubst eieio--class-object (class)
(or (cl--find-class class) class)
class))
+(defsubst eieio--object-class (obj)
+ (let ((tag (eieio--object-class-tag obj)))
+ (if eieio-backward-compatibility
+ (eieio--class-object tag)
+ tag)))
+
(defun class-p (x)
"Return non-nil if X is a valid class vector.
X can also be is a symbol."
@@ -163,7 +166,7 @@ (defsubst eieio--class-option (class option)
(defun eieio-object-p (obj)
"Return non-nil if OBJ is an EIEIO object."
(and (recordp obj)
- (eieio--class-p (eieio--object-class-tag obj))))
+ (eieio--class-p (eieio--object-class obj))))
(define-obsolete-function-alias 'object-p 'eieio-object-p "25.1")
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index 38436d1f94..864ac2616b 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -710,6 +710,9 @@ (cl-defmethod make-instance
;; Call the initialize method on the new object with the slots
;; that were passed down to us.
(initialize-instance new-object slots)
+ (when eieio-backward-compatibility
+ ;; Use symbol as type descriptor, for backwards compatibility.
+ (aset new-object 0 class))
;; Return the created object.
new-object))
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
index dfaa031844..f8a0aa30dd 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
@@ -297,8 +297,7 @@ (ert-deftest eieio-test-persist-hash-and-vector ()
(aset (car (slot-value class 'janitors)) 1 hans)
(aset (nth 1 (slot-value class 'janitors)) 1 dierdre)
(unwind-protect
- ;; FIXME: This should not error.
- (should-error (persist-test-save-and-compare class))
+ (persist-test-save-and-compare class)
(delete-file (oref class file)))))
;; Extra quotation of lists inside other objects (Gnus registry), also
@@ -335,8 +334,7 @@ (ert-deftest eieio-test-persist-interior-lists ()
(setf (nth 2 (cadar alst)) john
(nth 2 (cadadr alst)) alexie)
(unwind-protect
- ;; FIXME: Should not error.
- (should-error (persist-test-save-and-compare thing))
+ (persist-test-save-and-compare thing)
(delete-file (slot-value thing 'file)))))
;;; eieio-test-persist.el ends here
--
2.11.0
next prev parent reply other threads:[~2019-05-27 23:36 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 22:04 bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object Pierre Téchoueyres
2017-11-08 22:48 ` Eric Abrahamsen
2017-11-10 17:31 ` Pierre Téchoueyres
2017-11-10 18:12 ` Eric Abrahamsen
2017-11-10 18:32 ` Pierre Téchoueyres
2017-11-12 19:10 ` Noam Postavsky
2017-11-14 22:30 ` Pierre Téchoueyres
2017-11-15 2:02 ` Noam Postavsky
2017-11-15 15:29 ` Stefan Monnier
2017-11-17 19:56 ` Pierre Téchoueyres
2017-11-18 3:40 ` Noam Postavsky
2017-11-18 4:39 ` Eric Abrahamsen
2017-11-18 13:24 ` Noam Postavsky
2017-11-18 18:14 ` Eric Abrahamsen
2017-11-19 3:17 ` Noam Postavsky
2017-11-19 5:57 ` Eric Abrahamsen
2017-11-23 23:20 ` Pierre Téchoueyres
2017-11-24 0:09 ` Noam Postavsky
2017-11-28 21:39 ` Pierre Téchoueyres
2017-11-28 21:52 ` Noam Postavsky
2017-11-28 22:18 ` Pierre Téchoueyres
2017-11-29 1:09 ` Noam Postavsky
2017-11-29 15:18 ` Stefan Monnier
2017-11-28 22:10 ` Eric Abrahamsen
2017-11-29 15:15 ` Stefan Monnier
2017-12-01 17:25 ` Eric Abrahamsen
2017-12-01 17:55 ` Stefan Monnier
2017-12-03 0:17 ` Eric Abrahamsen
2017-12-03 18:35 ` Pierre Téchoueyres
2017-12-05 1:27 ` Eric Abrahamsen
2017-12-05 2:08 ` Stefan Monnier
2017-12-05 17:47 ` Eric Abrahamsen
2017-12-05 19:02 ` Stefan Monnier
2017-12-05 20:56 ` Eric Abrahamsen
2017-12-05 22:14 ` Stefan Monnier
2017-12-05 22:58 ` Eric Abrahamsen
2017-12-08 10:41 ` Eli Zaretskii
2017-12-09 16:59 ` Eric Abrahamsen
2017-12-12 23:21 ` Noam Postavsky
2017-12-15 20:26 ` Pierre Téchoueyres
2017-12-15 22:26 ` Pierre Téchoueyres
2017-12-16 23:42 ` Eric Abrahamsen
2018-02-20 19:50 ` Pierre Téchoueyres
2018-02-24 21:23 ` Eric Abrahamsen
2018-02-24 23:21 ` Pierre Téchoueyres
2018-02-24 23:40 ` Eric Abrahamsen
2018-02-25 0:34 ` Pierre Téchoueyres
2018-02-25 18:59 ` Eric Abrahamsen
2019-05-27 23:36 ` Noam Postavsky [this message]
2019-05-28 21:17 ` Eric Abrahamsen
2019-05-30 22:50 ` Noam Postavsky
2017-12-18 19:52 ` Eric Abrahamsen
2017-12-18 21:38 ` Stefan Monnier
2017-12-20 18:29 ` Eric Abrahamsen
2017-12-20 20:54 ` Stefan Monnier
2017-12-21 2:21 ` Eric Abrahamsen
2017-12-24 2:18 ` Eric Ludlam
2017-12-28 18:44 ` Eric Abrahamsen
2017-12-05 22:20 ` Pierre Téchoueyres
2018-01-24 19:17 ` Pierre Téchoueyres
2018-01-25 3:09 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v9xv79nf.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=29220@debbugs.gnu.org \
--cc=eric@ericabrahamsen.net \
--cc=jwiegley@gmail.com \
--cc=monnier@iro.umontreal.ca \
--cc=pierre.techoueyres@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.