From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#46722: test-map-into fails Date: Wed, 05 Jan 2022 12:51:09 -0500 Message-ID: References: <871r2yu8b1.fsf@gnus.org> <87czl7w4fh.fsf@dick> <87a6gawabq.fsf@dick> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17504"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: contovob@tcd.ie, Glenn Morris , Lars Ingebrigtsen , Stefan Kangas , 46722@debbugs.gnu.org To: dick Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 05 18:52:19 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5ASQ-0004Hx-LM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jan 2022 18:52:18 +0100 Original-Received: from localhost ([::1]:41904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5ASP-0002sC-4q for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jan 2022 12:52:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5ASD-0002rg-2v for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 12:52:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n5ASA-0006OL-7H for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 12:52:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n5ASA-00078W-65 for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 12:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jan 2022 17:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46722 X-GNU-PR-Package: emacs Original-Received: via spool by 46722-submit@debbugs.gnu.org id=B46722.164140508627381 (code B ref 46722); Wed, 05 Jan 2022 17:52:02 +0000 Original-Received: (at 46722) by debbugs.gnu.org; 5 Jan 2022 17:51:26 +0000 Original-Received: from localhost ([127.0.0.1]:41702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5ARZ-00077Z-OL for submit@debbugs.gnu.org; Wed, 05 Jan 2022 12:51:25 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:26161) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5ARY-00077K-Bl for 46722@debbugs.gnu.org; Wed, 05 Jan 2022 12:51:24 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5630280552; Wed, 5 Jan 2022 12:51:18 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D4C178044E; Wed, 5 Jan 2022 12:51:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1641405076; bh=MCliOC1M+0D6hI8PKQ6bL/iYlagBNNcOAycKB5RJrB8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Nus0OXoL9WavLOyaSXgqJLByKqkElm+Q387Z1iieVSJR77LYHWSMRjIFP+Y8XvgfT wLF/SfQa1J0EDPVaBAIC8KzjwxbWAkWWNNarXiB1sL+u104vWri2txziL5VeFBhqqc oi5Z75cxsGO5EeQ0SWpqVfGi7zUdGRf5o4xD/diUhzGrfDIRZMjlyml6yqDpGrPrMl TtbCWq9F2j/UopVgPoM8VVIAM6dRUM/RIuIPNK1zaVR0J4bz9now7G9MW7WaptNZY0 aJ7kUrB7hwmEPLqt82CQfVi5HgEcsT89+qbkDD6axJNBzAqQAwSqMhfAnpiBDc0OpF w191Tm1YNX1HA== Original-Received: from ceviche (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8FF24120493; Wed, 5 Jan 2022 12:51:16 -0500 (EST) In-Reply-To: (Stefan Monnier's message of "Wed, 05 Jan 2022 11:31:59 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:223704 Archived-At: 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))