aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd2024-04-14 18:20:47 +0200
committerMattias EngdegÄrd2024-04-14 18:29:16 +0200
commit3d3602055264ca3095b7f28ca7e27a6f2782649a (patch)
tree7611756442288e5095fe61a0bab1ab6d0f50fe80 /test
parent568c1741352a4932508fbbd474b9fd9ebe90ddfb (diff)
downloademacs-3d3602055264ca3095b7f28ca7e27a6f2782649a.tar.gz
emacs-3d3602055264ca3095b7f28ca7e27a6f2782649a.zip
GC-mark temporary key values created when sorting (bug#69709)
Bug reported and fix proposed by Aris Spathis. * src/sort.c (merge_markmem): Mark heap-allocated temporary key values. (tim_sort): Delay key function calls to after marking function has been registered. * test/src/fns-tests.el (fns-tests-sort-gc): New test.
Diffstat (limited to 'test')
-rw-r--r--test/src/fns-tests.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index 1b13785a9fc..5ba7e49324a 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -418,6 +418,27 @@
418 (should-not (and (> size 0) (eq res seq))) 418 (should-not (and (> size 0) (eq res seq)))
419 (should (equal seq input)))))))))))) 419 (should (equal seq input))))))))))))
420 420
421(ert-deftest fns-tests-sort-gc ()
422 ;; Make sure our temporary storage is traversed by the GC.
423 (let* ((n 1000)
424 (a (mapcar #'number-to-string (number-sequence 1 n)))
425 (i 0)
426 ;; Force frequent GCs in both the :key and :lessp functions.
427 (s (sort a
428 :key (lambda (x)
429 (setq i (1+ i))
430 (when (> i 300)
431 (garbage-collect)
432 (setq i 0))
433 (copy-sequence x))
434 :lessp (lambda (a b)
435 (setq i (1+ i))
436 (when (> i 300)
437 (garbage-collect)
438 (setq i 0))
439 (string< a b)))))
440 (should (equal (length s) (length a)))))
441
421(defvar w32-collate-ignore-punctuation) 442(defvar w32-collate-ignore-punctuation)
422 443
423(ert-deftest fns-tests-collate-sort () 444(ert-deftest fns-tests-collate-sort ()