aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorGemini Lasswell2018-10-14 12:12:04 -0700
committerGemini Lasswell2018-10-29 11:05:00 -0700
commit0e484c66fd63877230c3dfa97f2ce9dda71ad88b (patch)
treea7cf3670fdd67ce433329744c4e73f3b9214cd39 /test/src
parentb9c60200259a562f4762e8debf4646319d7a9332 (diff)
downloademacs-0e484c66fd63877230c3dfa97f2ce9dda71ad88b.tar.gz
emacs-0e484c66fd63877230c3dfa97f2ce9dda71ad88b.zip
Keep a stack reference to bytecode objects being executed (Bug#33014)
* src/eval.c (Ffuncall): Make local variable 'fun' volatile. * test/src/eval-tests.el (eval-tests-byte-code-being-evaluated-is-protected-from-gc): Add regression test for Bug#33014. (eval-tests-33014-var): New variable. (eval-tests-33014-func, eval-tests-33014-redefine): New functions.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/eval-tests.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 281d959b530..0c242913e7a 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -139,4 +139,34 @@ crash/abort/malloc assert failure on the next test."
139 (defvaralias 'eval-tests--foo-alias 'eval-tests--foo) 139 (defvaralias 'eval-tests--foo-alias 'eval-tests--foo)
140 'no-warning))))) 140 'no-warning)))))
141 141
142(ert-deftest eval-tests-byte-code-being-evaluated-is-protected-from-gc ()
143 "Regression test for Bug#33014.
144Check that byte-compiled objects being executed by exec-byte-code
145are found on the stack and therefore not garbage collected."
146 (should (string= (eval-tests-33014-func)
147 "before after: ok foo: (e) bar: (a b c d e) baz: a bop: c")))
148
149(defvar eval-tests-33014-var "ok")
150(defun eval-tests-33014-func ()
151 "A function which has a non-trivial constants vector when byte-compiled."
152 (let ((result "before "))
153 (eval-tests-33014-redefine)
154 (garbage-collect)
155 (setq result (concat result (format "after: %s" eval-tests-33014-var)))
156 (let ((vals '(0 1 2 3))
157 (things '(a b c d e)))
158 (dolist (val vals)
159 (setq result
160 (concat result " "
161 (cond
162 ((= val 0) (format "foo: %s" (last things)))
163 ((= val 1) (format "bar: %s" things))
164 ((= val 2) (format "baz: %s" (car things)))
165 (t (format "bop: %s" (nth 2 things))))))))
166 result))
167
168(defun eval-tests-33014-redefine ()
169 "Remove the Lisp reference to the byte-compiled object."
170 (setf (symbol-function #'eval-tests-33014-func) nil))
171
142;;; eval-tests.el ends here 172;;; eval-tests.el ends here