astepano / rpms / vim

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