summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-07 14:05:24 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-07 14:05:24 +0200
commit6cc7e21412487ff8bd531c73ac9325f5ba2409a9 (patch)
tree7bcd9498467c8b459695c69abac1e9253692ff89
parentc2f5054be9301c8a47b92a4584338cb2de24b96c (diff)
patch 8.1.1641: garbage collection may run at a wrong momentv8.1.1641
Problem: Garbage collection may run at a wrong moment. (Trygve Aaberge) Solution: Postpone garbage collection while parsing messages. (closes #4620)
-rw-r--r--src/misc2.c9
-rw-r--r--src/version.c2
2 files changed, 11 insertions, 0 deletions
diff --git a/src/misc2.c b/src/misc2.c
index 892fbc56a8..000f043e13 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -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)
diff --git a/src/version.c b/src/version.c
index 85cf7b2e21..663f92f49d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1641,
+/**/
1640,
/**/
1639,