diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-26 12:03:20 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-30 21:00:17 -0400 |
commit | 4edf7b9ff22ca702876a7d0b5534fa2fc16b1897 (patch) | |
tree | c92b7fdf153bf781a65c9edbd8eeab55ef63091b /src/nvim/testdir/test_mapping.vim | |
parent | 7cb38d5ac41efc1dce80a2e40c9c55f8a3802d61 (diff) | |
download | rneovim-4edf7b9ff22ca702876a7d0b5534fa2fc16b1897.tar.gz rneovim-4edf7b9ff22ca702876a7d0b5534fa2fc16b1897.tar.bz2 rneovim-4edf7b9ff22ca702876a7d0b5534fa2fc16b1897.zip |
vim-patch:8.1.1591: on error garbage collection may free memory in use
Problem: On error garbage collection may free memory in use.
Solution: Reset may_garbage_collect when evaluating expression mapping.
Add tests. (Ozaki Kiichi, closes vim/vim#4579)
https://github.com/vim/vim/commit/7d491c425334d9477637372a4ebec64c228c8430
Diffstat (limited to 'src/nvim/testdir/test_mapping.vim')
-rw-r--r-- | src/nvim/testdir/test_mapping.vim | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 82562339f6..dd0da5db64 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -391,6 +391,42 @@ func Test_motionforce_omap() delfunc GetCommand endfunc +func Test_error_in_map_expr() + if !has('terminal') || (has('win32') && has('gui_running')) + throw 'Skipped: cannot run Vim in a terminal window' + endif + + let lines =<< trim [CODE] + func Func() + " fail to create list + let x = [ + endfunc + nmap <expr> ! Func() + set updatetime=50 + [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 map-expr processing, which can make Vim crash. + call term_sendkeys(buf, '!') + 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 + " Test for mapping errors func Test_map_error() call assert_fails('unmap', 'E474:') |