Hi Sean!
On Mo, 17 Dez 2012, Sean Reifschneider wrote:
> Since vim 7.3 patch 429 (on Ubuntu Precise/12.04), it looks like there's a
> segfault issue when doing "cclose" on BufUnload in a python function. In
> particular, it happens on 7.3 patch 547 (Ubuntu Quantal/12.10), and is also
> happening on 7.3 patch 762 (latest tag in Mercurial checkout).
>
> Here's how I'm able to reproduce it:
>
> Create a file /tmp/blowup.vim:
>
> pyfile /tmp/blowup.py
> botright 3copen
> autocmd BufUnload * python leaving_buffer()
>
> Then create a file /tmp/blowup.py:
>
> import vim
> def leaving_buffer():
> vim.command('cclose')
> vim.command('quit')
>
> Now run "vim -u tmp/blowup.vim /tmp/foo" (in my case, /tmp/foo does not
> exist). Do ":q" in vim, and it will segfault:
>
> Vim: Caught deadly signal SEGV
> zsh: segmentation fault (core dumped) vim -u /tmp/blowup.vim /tmp/foo
>
This is an issue, that seems to come up in one or another form every
couple of months here. The root cause is always autocommands closing all
windows and buffers, which Vim does not expect and so it crashes sooner
or later. Here is a patch, trying to prevent this another time:
diff --git a/src/main.c b/src/main.c
--- a/src/main.c
+++ b/src/main.c
@@ -1376,6 +1376,8 @@
for (wp = (tp == curtab)
? firstwin : tp->tp_firstwin; wp != NULL; wp = wp->w_next)
{
+ if (wp->w_buffer == NULL)
+ continue;
buf = wp->w_buffer;
if (buf->b_changedtick != -1)
{
diff --git a/src/window.c b/src/window.c
--- a/src/window.c
+++ b/src/window.c
@@ -2276,9 +2276,13 @@
#endif
}
+ if ( only_one_window() && (!win_valid(win) || last_window() || curtab !=
prev_curtab
+ || close_last_window_tabpage(win, free_buf, prev_curtab)))
+ /* autocommands have close all windows, quit now */
+ getout(0);
/* Autocommands may have closed the window already, or closed the only
* other window or moved to another tab page. */
- if (!win_valid(win) || last_window() || curtab != prev_curtab
+ else if (!win_valid(win) || last_window() || curtab != prev_curtab
|| close_last_window_tabpage(win, free_buf, prev_curtab))
return;
@@ -6281,7 +6285,7 @@
if (first_tabpage->tp_next != NULL)
return FALSE;
- for (wp = firstwin; wp != NULL; wp = wp->w_next)
+ for (wp = firstwin; wp != NULL && wp->w_buffer != NULL; wp = wp->w_next)
if ((!((wp->w_buffer->b_help && !curbuf->b_help)
# ifdef FEAT_QUICKFIX
|| wp->w_p_pvw
This does quit Vim, in case an autocommand closes all other
windows/buffers while Vim is processing the win_close() function.
regards,
Christian
--
Wer in einem gewissen Alter nicht merkt, daß er hauptsächlich
von Idioten umgeben ist, merkt es aus einem gewissen Grunde nicht.
-- Curt Goetz
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php