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