3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.022
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.022
3ef2ca
Problem:    Deadlock while exiting, because of allocating memory.
3ef2ca
Solution:   Do not use gettext() in deathtrap(). (James McCoy)
3ef2ca
Files:	    src/os_unix.c, src/misc1.c
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.021/src/os_unix.c	2013-07-03 16:32:32.000000000 +0200
3ef2ca
--- src/os_unix.c	2013-09-05 21:40:06.000000000 +0200
3ef2ca
***************
3ef2ca
*** 957,964 ****
3ef2ca
  
3ef2ca
  /*
3ef2ca
   * This function handles deadly signals.
3ef2ca
!  * It tries to preserve any swap file and exit properly.
3ef2ca
   * (partly from Elvis).
3ef2ca
   */
3ef2ca
      static RETSIGTYPE
3ef2ca
  deathtrap SIGDEFARG(sigarg)
3ef2ca
--- 957,966 ----
3ef2ca
  
3ef2ca
  /*
3ef2ca
   * This function handles deadly signals.
3ef2ca
!  * It tries to preserve any swap files and exit properly.
3ef2ca
   * (partly from Elvis).
3ef2ca
+  * NOTE: Avoid unsafe functions, such as allocating memory, they can result in
3ef2ca
+  * a deadlock.
3ef2ca
   */
3ef2ca
      static RETSIGTYPE
3ef2ca
  deathtrap SIGDEFARG(sigarg)
3ef2ca
***************
3ef2ca
*** 1090,1107 ****
3ef2ca
      }
3ef2ca
      if (entered == 2)
3ef2ca
      {
3ef2ca
! 	OUT_STR(_("Vim: Double signal, exiting\n"));
3ef2ca
  	out_flush();
3ef2ca
  	getout(1);
3ef2ca
      }
3ef2ca
  
3ef2ca
  #ifdef SIGHASARG
3ef2ca
!     sprintf((char *)IObuff, _("Vim: Caught deadly signal %s\n"),
3ef2ca
  							 signal_info[i].name);
3ef2ca
  #else
3ef2ca
!     sprintf((char *)IObuff, _("Vim: Caught deadly signal\n"));
3ef2ca
  #endif
3ef2ca
!     preserve_exit();		    /* preserve files and exit */
3ef2ca
  
3ef2ca
  #ifdef NBDEBUG
3ef2ca
      reset_signals();
3ef2ca
--- 1092,1114 ----
3ef2ca
      }
3ef2ca
      if (entered == 2)
3ef2ca
      {
3ef2ca
! 	/* No translation, it may call malloc(). */
3ef2ca
! 	OUT_STR("Vim: Double signal, exiting\n");
3ef2ca
  	out_flush();
3ef2ca
  	getout(1);
3ef2ca
      }
3ef2ca
  
3ef2ca
+     /* No translation, it may call malloc(). */
3ef2ca
  #ifdef SIGHASARG
3ef2ca
!     sprintf((char *)IObuff, "Vim: Caught deadly signal %s\n",
3ef2ca
  							 signal_info[i].name);
3ef2ca
  #else
3ef2ca
!     sprintf((char *)IObuff, "Vim: Caught deadly signal\n");
3ef2ca
  #endif
3ef2ca
! 
3ef2ca
!     /* Preserve files and exit.  This sets the really_exiting flag to prevent
3ef2ca
!      * calling free(). */
3ef2ca
!     preserve_exit();
3ef2ca
  
3ef2ca
  #ifdef NBDEBUG
3ef2ca
      reset_signals();
3ef2ca
*** ../vim-7.4.021/src/misc1.c	2013-08-03 17:29:33.000000000 +0200
3ef2ca
--- src/misc1.c	2013-09-05 21:34:04.000000000 +0200
3ef2ca
***************
3ef2ca
*** 9174,9179 ****
3ef2ca
--- 9174,9181 ----
3ef2ca
  /*
3ef2ca
   * Preserve files and exit.
3ef2ca
   * When called IObuff must contain a message.
3ef2ca
+  * NOTE: This may be called from deathtrap() in a signal handler, avoid unsafe
3ef2ca
+  * functions, such as allocating memory.
3ef2ca
   */
3ef2ca
      void
3ef2ca
  preserve_exit()
3ef2ca
***************
3ef2ca
*** 9196,9202 ****
3ef2ca
      {
3ef2ca
  	if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)
3ef2ca
  	{
3ef2ca
! 	    OUT_STR(_("Vim: preserving files...\n"));
3ef2ca
  	    screen_start();	    /* don't know where cursor is now */
3ef2ca
  	    out_flush();
3ef2ca
  	    ml_sync_all(FALSE, FALSE);	/* preserve all swap files */
3ef2ca
--- 9198,9204 ----
3ef2ca
      {
3ef2ca
  	if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)
3ef2ca
  	{
3ef2ca
! 	    OUT_STR("Vim: preserving files...\n");
3ef2ca
  	    screen_start();	    /* don't know where cursor is now */
3ef2ca
  	    out_flush();
3ef2ca
  	    ml_sync_all(FALSE, FALSE);	/* preserve all swap files */
3ef2ca
***************
3ef2ca
*** 9206,9212 ****
3ef2ca
  
3ef2ca
      ml_close_all(FALSE);	    /* close all memfiles, without deleting */
3ef2ca
  
3ef2ca
!     OUT_STR(_("Vim: Finished.\n"));
3ef2ca
  
3ef2ca
      getout(1);
3ef2ca
  }
3ef2ca
--- 9208,9214 ----
3ef2ca
  
3ef2ca
      ml_close_all(FALSE);	    /* close all memfiles, without deleting */
3ef2ca
  
3ef2ca
!     OUT_STR("Vim: Finished.\n");
3ef2ca
  
3ef2ca
      getout(1);
3ef2ca
  }
3ef2ca
*** ../vim-7.4.021/src/version.c	2013-09-05 21:15:38.000000000 +0200
3ef2ca
--- src/version.c	2013-09-05 21:30:18.000000000 +0200
3ef2ca
***************
3ef2ca
*** 740,741 ****
3ef2ca
--- 740,743 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     22,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
hundred-and-one symptoms of being an internet addict:
3ef2ca
175. You send yourself e-mail before you go to bed to remind you
3ef2ca
     what to do when you wake up.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///