As one of my users discovered[0], if Vim is killed and autocmds are run
as part of the shutdown, Vim will crash instead of closing gracefully.
From what I can tell, it looks like Vim is exceeding the stack since the
shutdown process (and autocmds) are being run in the context of the
alternate signal stack and that stack is likely only 8k.

This can readily be reproduced using the attached crash.vim.

  $ vim -u crash.vim --noplugin -N
  $ kill $pidOfVim
  Vim: Caught deadly signal TERM
  Vim: Finished.
  Vim: Double signal, exiting

If it is indeed a problem with exceeding the stack, then two possible
solutions seem evident to me.

1) Change the signal handler to simply set a flag that Vim needs to
   exit, return from the signal handler, have another portion of the
   code that checks for that flag (RealWaitForChar ?), and initiate the
   shutdown steps from there.

2) Ignore autocommands if Vim is exiting due to a deadly signal.  Just
   do the minimum necessary steps to gracefully exit -- i.e., flush out
   the swapfiles, viminfo, and quit.

The attached patch does 2) but 1) seems like a more robust (although
potentially more invasive) change.

[0]: http://bugs.debian.org/580961
-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[email protected]>

Attachment: signature.asc
Description: Digital signature

Raspunde prin e-mail lui