From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object. Date: Mon, 27 May 2019 19:36:04 -0400 Message-ID: <87v9xv79nf.fsf@gmail.com> References: <87y3nga0lv.fsf@killashandra.ballybran.fr> <87zi6zmzh7.fsf@killashandra.ballybran.fr> <87h8t69d7b.fsf@ericabrahamsen.net> <87609lcbip.fsf@ericabrahamsen.net> <87bmjcc2rh.fsf@ericabrahamsen.net> <874lp4aije.fsf@ericabrahamsen.net> <83po7pwlgs.fsf@gnu.org> <87lgib4z2o.fsf@ericabrahamsen.net> <87wp1rcz21.fsf@users.sourceforge.net> <87mv2jkaap.fsf@killashandra.ballybran.fr> <87wp1nsk52.fsf@killashandra.ballybran.fr> <87y3m2jl3b.fsf@ericabrahamsen.net> <871shf30fn.fsf@killashandra.ballybran.fr> <87woz2qdyo.fsf@ericabrahamsen.net> <877er23rev.fsf@killashandra.ballybran.fr> <87sh9qufb2.fsf@ericabrahamsen.net> <87muzx52l7.fsf@killashandra.ballybran.fr> <87h8q4uc8x.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="140137"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: jwiegley@gmail.com, 29220@debbugs.gnu.org, monnier@iro.umontreal.ca, Pierre =?UTF-8?Q?T=C3=A9choueyres?= To: Eric Abrahamsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 28 01:37:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVPB1-000aK8-Rj for geb-bug-gnu-emacs@m.gmane.org; Tue, 28 May 2019 01:37:12 +0200 Original-Received: from localhost ([127.0.0.1]:54551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVPB0-0000Cj-C5 for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 May 2019 19:37:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:34842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVPAt-0000CS-ME for bug-gnu-emacs@gnu.org; Mon, 27 May 2019 19:37:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVPAs-0006pp-7u for bug-gnu-emacs@gnu.org; Mon, 27 May 2019 19:37:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40975) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVPAr-0006pb-UR for bug-gnu-emacs@gnu.org; Mon, 27 May 2019 19:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hVPAr-0007cv-Mx for bug-gnu-emacs@gnu.org; Mon, 27 May 2019 19:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 May 2019 23:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29220 X-GNU-PR-Package: emacs Original-Received: via spool by 29220-submit@debbugs.gnu.org id=B29220.155900017629250 (code B ref 29220); Mon, 27 May 2019 23:37:01 +0000 Original-Received: (at 29220) by debbugs.gnu.org; 27 May 2019 23:36:16 +0000 Original-Received: from localhost ([127.0.0.1]:54517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVPA7-0007bi-FH for submit@debbugs.gnu.org; Mon, 27 May 2019 19:36:15 -0400 Original-Received: from mail-it1-f175.google.com ([209.85.166.175]:53765) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVPA5-0007bQ-Ib for 29220@debbugs.gnu.org; Mon, 27 May 2019 19:36:14 -0400 Original-Received: by mail-it1-f175.google.com with SMTP id m141so1416636ita.3 for <29220@debbugs.gnu.org>; Mon, 27 May 2019 16:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=aT6Tleh9Ng/Qqv7E7g2qIDK6JjGgY2mce2KHahG2DHA=; b=ZIr4+8vX4eKcO1kQ4VvdmQggJ+krEHhujF0AnCkGO9ucOfu6jN+cBR4vH1BGWU5q3b 34Xmhi6i4EheOhOt+AYAV0C5BysKP4wCLfqnaSBbTUthefjI+47ZuzI1ANY4LwUxUkD5 olABCjBY2Ksw+4fhqgsxwYU6x2YKHL3FrB/El/3PgJ1BtYBQ8uZlCkQaNVi/qhYg3qyt kS53yBHjpU7v7u9uTbNNW1zUqJqhjfiyJgJVosfxy645Cg/zNQSjQ6nYxHjAIBJ9oL+Y RgXwZw65q4XwmznfGddd2R2Zi6CI2tQ9n8dFIyF5VQPf2Y0y349JHxn8Peb65GFGpBeR tMOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=aT6Tleh9Ng/Qqv7E7g2qIDK6JjGgY2mce2KHahG2DHA=; b=sIc+ErB2Jpmxl2JmQegD5oFtx+RQyYG/UYQPrZL+BTB9ehY3WjbXR+o8yI1Z3rEQkA Fk2k16BVe8C7F4HdzqSqFgpjiJSfNOasSyXBV/2Faom9SEyx33c8DxkatUvWOQbywetC K8QqN6VlIwVQmCnILTa+XamgVuJg/wKrb0maVcvDycR5yezLW9UJJK8j2QZ/WnJ+xs9s MfUUfrr26riSpz0dFG1z2ZPgnzEKi4bQ20Yf5vvzn6AqHi8Iq0M3E1Sy9J3Orgy0rJBq Ks6MhVKPlisKCEKIG4cN5YpR9+QCUx1QO6jBYLzC/zzk1Jx8fRN9cMnYJjzQr2sJnok3 0qxA== X-Gm-Message-State: APjAAAVADYJplgzjy7mzFSzcE1Wqdjc7U1WtGrjVI4g4X4iTWot2jXuX Wgmy2cCgS9v0v2eXDeWV/v8= X-Google-Smtp-Source: APXvYqxJ3nnTsg5NKGLNU71y2FGpeZlH/snhuFSybuaaQSAVGJPpge7I6iLUG8FaV/Ytzm9mVYgAiQ== X-Received: by 2002:a24:7592:: with SMTP id y140mr1165622itc.47.1559000167797; Mon, 27 May 2019 16:36:07 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id t26sm4028801ioc.66.2019.05.27.16.36.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 May 2019 16:36:06 -0700 (PDT) In-Reply-To: <87h8q4uc8x.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 25 Feb 2018 10:59:10 -0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159834 Archived-At: --=-=-= Content-Type: text/plain Eric Abrahamsen 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Use-plain-symbols-for-eieio-type-descriptors-Bug-292.patch Content-Description: patch >From f6cc4509073da4ff23a4227d48b33108b1e96828 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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)) - ;;; 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 --=-=-=--