patch 8.1.1579: dict and list could be GC'ed while displaying error
Problem: Dict and list could be GC'ed while displaying error in a timer.
(Yasuhiro Matsumoto)
Solution: Block garbage collection when executing a timer. Add
test_garbagecollect_soon(). Add "no_wait_return" to
test_override(). (closes #4571)
diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim
index 03391d8..e67da13 100644
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -309,4 +309,28 @@
call delete('Xtrctext')
endfunc
+" Test that the garbage collector isn't triggered if a timer callback invokes
+" vgetc().
+func Test_nocatch_garbage_collect()
+ " 'uptimetime. must be bigger than the timer timeout
+ set ut=200
+ call test_garbagecollect_soon()
+ call test_override('no_wait_return', 0)
+ func CauseAnError(id)
+ " This will show an error and wait for Enter.
+ let a = {'foo', 'bar'}
+ endfunc
+ func FeedChar(id)
+ call feedkeys('x', 't')
+ endfunc
+ call timer_start(300, 'FeedChar')
+ call timer_start(100, 'CauseAnError')
+ let x = getchar()
+
+ set ut&
+ call test_override('no_wait_return', 1)
+ delfunc CauseAnError
+ delfunc FeedChar
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab