Skip to content

Commit 842c4dd

Browse files
committed
updated for version 7.4.022
Problem: Deadlock while exiting, because of allocating memory. Solution: Do not use gettext() in deathtrap(). (James McCoy)
1 parent c33239d commit 842c4dd

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/misc1.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9174,6 +9174,8 @@ prepare_to_exit()
91749174
/*
91759175
* Preserve files and exit.
91769176
* When called IObuff must contain a message.
9177+
* NOTE: This may be called from deathtrap() in a signal handler, avoid unsafe
9178+
* functions, such as allocating memory.
91779179
*/
91789180
void
91799181
preserve_exit()
@@ -9196,7 +9198,7 @@ preserve_exit()
91969198
{
91979199
if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)
91989200
{
9199-
OUT_STR(_("Vim: preserving files...\n"));
9201+
OUT_STR("Vim: preserving files...\n");
92009202
screen_start(); /* don't know where cursor is now */
92019203
out_flush();
92029204
ml_sync_all(FALSE, FALSE); /* preserve all swap files */
@@ -9206,7 +9208,7 @@ preserve_exit()
92069208

92079209
ml_close_all(FALSE); /* close all memfiles, without deleting */
92089210

9209-
OUT_STR(_("Vim: Finished.\n"));
9211+
OUT_STR("Vim: Finished.\n");
92109212

92119213
getout(1);
92129214
}

src/os_unix.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,10 @@ mch_didjmp()
957957

958958
/*
959959
* This function handles deadly signals.
960-
* It tries to preserve any swap file and exit properly.
960+
* It tries to preserve any swap files and exit properly.
961961
* (partly from Elvis).
962+
* NOTE: Avoid unsafe functions, such as allocating memory, they can result in
963+
* a deadlock.
962964
*/
963965
static RETSIGTYPE
964966
deathtrap SIGDEFARG(sigarg)
@@ -1090,18 +1092,23 @@ deathtrap SIGDEFARG(sigarg)
10901092
}
10911093
if (entered == 2)
10921094
{
1093-
OUT_STR(_("Vim: Double signal, exiting\n"));
1095+
/* No translation, it may call malloc(). */
1096+
OUT_STR("Vim: Double signal, exiting\n");
10941097
out_flush();
10951098
getout(1);
10961099
}
10971100

1101+
/* No translation, it may call malloc(). */
10981102
#ifdef SIGHASARG
1099-
sprintf((char *)IObuff, _("Vim: Caught deadly signal %s\n"),
1103+
sprintf((char *)IObuff, "Vim: Caught deadly signal %s\n",
11001104
signal_info[i].name);
11011105
#else
1102-
sprintf((char *)IObuff, _("Vim: Caught deadly signal\n"));
1106+
sprintf((char *)IObuff, "Vim: Caught deadly signal\n");
11031107
#endif
1104-
preserve_exit(); /* preserve files and exit */
1108+
1109+
/* Preserve files and exit. This sets the really_exiting flag to prevent
1110+
* calling free(). */
1111+
preserve_exit();
11051112

11061113
#ifdef NBDEBUG
11071114
reset_signals();

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
22,
741743
/**/
742744
21,
743745
/**/

0 commit comments

Comments
 (0)