summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_autocmd.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-03-19 17:09:56 +0100
committerBram Moolenaar <Bram@vim.org>2017-03-19 17:09:56 +0100
commit8c752bd6c4af54c0b7bac35a39acc2bf16015f85 (patch)
treed3d5fed20e6d7bb27a955eb129c8cfec0fc04bcb /src/testdir/test_autocmd.vim
parent4520d440c59034452d1450b27fcd56825c090687 (diff)
patch 8.0.0486: crash and endless loop when closing windows in autocmdv8.0.0486
Problem: Crash and endless loop when closing windows in a SessionLoadPost autocommand. Solution: Check for valid tabpage. (partly neovim #6308)
Diffstat (limited to 'src/testdir/test_autocmd.vim')
-rw-r--r--src/testdir/test_autocmd.vim63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index df6a868b29..b7487522ce 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -345,3 +345,66 @@ func Test_BufEnter()
call delete('Xdir', 'd')
au! BufEnter
endfunc
+
+" Closing a window might cause an endless loop
+" E814 for older Vims
+function Test_autocmd_bufwipe_in_SessLoadPost()
+ tabnew
+ set noswapfile
+ let g:bufnr=bufnr('%')
+ mksession!
+
+ let content=['set nocp noswapfile',
+ \ 'let v:swapchoice="e"',
+ \ 'augroup test_autocmd_sessionload',
+ \ 'autocmd!',
+ \ 'autocmd SessionLoadPost * 4bw!',
+ \ 'augroup END'
+ \ ]
+ call writefile(content, 'Xvimrc')
+ let a=system(v:progpath. ' -u Xvimrc --noplugins -S Session.vim')
+ call assert_match('E814', a)
+
+ unlet! g:bufnr
+ set swapfile
+ for file in ['Session.vim', 'Xvimrc']
+ call delete(file)
+ endfor
+endfunc
+
+" SEGV occurs in older versions.
+function Test_autocmd_bufwipe_in_SessLoadPost2()
+ tabnew
+ set noswapfile
+ let g:bufnr=bufnr('%')
+ mksession!
+
+ let content = ['set nocp noswapfile',
+ \ 'function! DeleteInactiveBufs()',
+ \ ' tabfirst',
+ \ ' let tabblist = []',
+ \ ' for i in range(1, tabpagenr(''$''))',
+ \ ' call extend(tabblist, tabpagebuflist(i))',
+ \ ' endfor',
+ \ ' for b in range(1, bufnr(''$''))',
+ \ ' if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')',
+ \ ' exec ''bwipeout '' . b',
+ \ ' endif',
+ \ ' endfor',
+ \ 'call append("1", "SessionLoadPost DONE")',
+ \ 'endfunction',
+ \ 'au SessionLoadPost * call DeleteInactiveBufs()']
+ call writefile(content, 'Xvimrc')
+ let a=system(v:progpath. ' -u Xvimrc --noplugins -S Session.vim')
+ " this probably only matches on unix
+ if has("unix")
+ call assert_notmatch('Caught deadly signal SEGV', a)
+ endif
+ call assert_match('SessionLoadPost DONE', a)
+
+ unlet! g:bufnr
+ set swapfile
+ for file in ['Session.vim', 'Xvimrc']
+ call delete(file)
+ endfor
+endfunc