]> granicus.if.org Git - vim/commitdiff
patch 8.1.1641: garbage collection may run at a wrong moment v8.1.1641
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Jul 2019 12:05:24 +0000 (14:05 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Jul 2019 12:05:24 +0000 (14:05 +0200)
Problem:    Garbage collection may run at a wrong moment. (Trygve Aaberge)
Solution:   Postpone garbage collection while parsing messages. (closes #4620)

src/misc2.c
src/version.c

index 892fbc56a8d5778d4ec9162e557e917ea1eefc34..000f043e138dc74c672afba041f7487abfde6740 100644 (file)
@@ -4444,12 +4444,19 @@ parse_queued_messages(void)
 {
     win_T   *old_curwin = curwin;
     int            i;
+    int            save_may_garbage_collect = may_garbage_collect;
 
     // Do not handle messages while redrawing, because it may cause buffers to
     // change or be wiped while they are being redrawn.
     if (updating_screen)
        return;
 
+    // may_garbage_collect is set in main_loop() to do garbage collection when
+    // blocking to wait on a character.  We don't want that while parsing
+    // messages, a callback may invoke vgetc() while lists and dicts are in use
+    // in the call stack.
+    may_garbage_collect = FALSE;
+
     // Loop when a job ended, but don't keep looping forever.
     for (i = 0; i < MAX_REPEAT_PARSE; ++i)
     {
@@ -4485,6 +4492,8 @@ parse_queued_messages(void)
        break;
     }
 
+    may_garbage_collect = save_may_garbage_collect;
+
     // If the current window changed we need to bail out of the waiting loop.
     // E.g. when a job exit callback closes the terminal window.
     if (curwin != old_curwin)
index 85cf7b2e21f1ecd608feffeb0abe954a30b293d4..663f92f49d1fd66661a6bc7116c97911a8801154 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1641,
 /**/
     1640,
 /**/