summaryrefslogtreecommitdiff
path: root/src/testdir/test_timers.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-25 06:28:02 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-25 06:28:02 +0200
commit7d491c425334d9477637372a4ebec64c228c8430 (patch)
tree27ab26e8fefb0dff30c8d7e98a7cc7ab2853dc24 /src/testdir/test_timers.vim
parent6c6a603cd2db9cbd51c9b4e3ff44cbab72b98592 (diff)
downloadvim-git-7d491c425334d9477637372a4ebec64c228c8430.tar.gz
patch 8.1.1591: on error garbage collection may free memory in usev8.1.1591
Problem: On error garbage collection may free memory in use. Solution: Reset may_garbage_collect when evaluating expression mapping. Add tests. (Ozaki Kiichi, closes #4579)
Diffstat (limited to 'src/testdir/test_timers.vim')
-rw-r--r--src/testdir/test_timers.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim
index 906613497..de13bcbe8 100644
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -333,4 +333,39 @@ func Test_nocatch_garbage_collect()
delfunc FeedChar
endfunc
+func Test_error_in_timer_callback()
+ if !has('terminal') || (has('win32') && has('gui_running'))
+ throw 'Skipped: cannot run Vim in a terminal window'
+ endif
+
+ let lines =<< trim [CODE]
+ func Func(timer)
+ " fail to create list
+ let x = [
+ endfunc
+ set updatetime=50
+ call timer_start(1, 'Func')
+ [CODE]
+ call writefile(lines, 'Xtest.vim')
+
+ let buf = term_start(GetVimCommandClean() .. ' -S Xtest.vim', {'term_rows': 8})
+ let job = term_getjob(buf)
+ call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))})
+
+ " GC must not run during timer callback, which can make Vim crash.
+ call term_wait(buf, 100)
+ call term_sendkeys(buf, "\<CR>")
+ call term_wait(buf, 100)
+ call assert_equal('run', job_status(job))
+
+ call term_sendkeys(buf, ":qall!\<CR>")
+ call WaitFor({-> job_status(job) ==# 'dead'})
+ if has('unix')
+ call assert_equal('', job_info(job).termsig)
+ endif
+
+ call delete('Xtest.vim')
+ exe buf .. 'bwipe!'
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab