From: Andrea Corallo Date: Wed, 23 Dec 2020 09:46:33 +0000 (+0100) Subject: Make input constraints into memoization hash immutable (bug#45376) X-Git-Tag: emacs-28.0.90~2727^2~233 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd8dd75a71eef796ba8fb1d2604fd615bebaae42;p=emacs.git Make input constraints into memoization hash immutable (bug#45376) * lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1) (comp-cstr-intersection): Copy input before soting it into the memoization hash table. --- diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index aaeb9cf3e9b..480d15616a0 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -507,7 +507,7 @@ DST is returned." (comp-cstr-ctxt-union-1-mem-no-range comp-ctxt))) (res (or (gethash srcs mem-h) (puthash - srcs + (mapcar #'comp-cstr-copy srcs) (apply #'comp-cstr-union-1-no-mem range srcs) mem-h)))) (setf (typeset dst) (typeset res) @@ -676,7 +676,7 @@ DST is returned." (let* ((mem-h (comp-cstr-ctxt-intersection-mem comp-ctxt)) (res (or (gethash srcs mem-h) (puthash - srcs + (mapcar #'comp-cstr-copy srcs) (apply #'comp-cstr-intersection-no-mem srcs) mem-h)))) (setf (typeset dst) (typeset res) diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el index a2663eaf9cf..d6bcfca2d94 100644 --- a/test/src/comp-test-funcs.el +++ b/test/src/comp-test-funcs.el @@ -417,6 +417,20 @@ (setq args (cons (substring arg start pos) args)))) args)) +(defun comp-test-45376-f () + ;; Reduced from `eshell-ls-find-column-lengths'. + (let* (res + (len 2) + (i 0) + (j 0)) + (while (< j len) + (if (= i len) + (setq i 0)) + (setq res (cons i res) + j (1+ j) + i (1+ i))) + res)) + ;;;;;;;;;;;;;;;;;;;; ;; Tromey's tests ;; diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 0594a4e086c..5f2d702fca0 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -409,6 +409,10 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." "Broken call args assumptions lead to infinite loop." (should (equal (comp-test-assume-in-loop-1-f "cd") '("cd")))) +(comp-deftest bug-45376 () + "" + (should (equal (comp-test-45376-f) '(1 0)))) + (defvar comp-test-primitive-advice) (comp-deftest primitive-advice () "Test effectiveness of primitive advicing."