GNU bug report logs - #46722
test-map-into fails

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Tue, 23 Feb 2021 16:23:01 UTC

Severity: normal

Merged with 53365

Found in versions 27.2, 28.0.50, 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: dick <dick.r.chiang <at> gmail.com>
Cc: contovob <at> tcd.ie, Glenn Morris <rgm <at> gnu.org>, Lars Ingebrigtsen <larsi <at> gnus.org>, Stefan Kangas <stefan <at> marxist.se>, 46722 <at> debbugs.gnu.org
Subject: bug#46722: test-map-into fails
Date: Wed, 05 Jan 2022 12:51:09 -0500
I think I tracked it down.

The patch below should fix it.  Boy do I hate side effects!
Could others confirm that it fixes the problem for them as well?

Eli, do you think this is appropriate for `emacs-28`?
OT1H this bug probably has been with us since Emacs-25, but OTOH the
patch should be very safe.


        Stefan


PS: We don't need the `copy-sequence` when we do the actual `gethash`,
we only need it if that `gethash` returns nil and we end up putting
a new entry in the hash-table, but avoiding those extra `copy-sequence`
requires manually macroexpanding `with-memoization`, so I favored
keeping the patch as short as possible.


diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 983694204df..5090e060372 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -604,7 +604,9 @@ cl--generic-dispatchers
 
 (defun cl--generic-get-dispatcher (dispatch)
   (with-memoization
-      (gethash dispatch cl--generic-dispatchers)
+      ;; We need `copy-sequence` here because this `dispatch' object might be
+      ;; modified by side-effect in `cl-generic-define-method' (bug#46722).
+      (gethash (copy-sequence dispatch) cl--generic-dispatchers)
     ;; (message "cl--generic-get-dispatcher (%S)" dispatch)
     (let* ((dispatch-arg (car dispatch))
            (generalizers (cdr dispatch))





This bug report was last modified 3 years and 123 days ago.

Previous Next


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