Skip to content

Commit 3fbcc12

Browse files
committed
patch 8.2.0061: the execute stack can grow big and never shrinks
Problem: The execute stack can grow big and never shrinks. Solution: Reduce the size in gargage collect.
1 parent d0337e3 commit 3fbcc12

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/eval.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,6 +3857,30 @@ garbage_collect(int testing)
38573857
garbage_collect_at_exit = FALSE;
38583858
}
38593859

3860+
// The execution stack can grow big, limit the size.
3861+
if (exestack.ga_maxlen - exestack.ga_len > 500)
3862+
{
3863+
size_t new_len;
3864+
char_u *pp;
3865+
int n;
3866+
3867+
// Keep 150% of the current size, with a minimum of the growth size.
3868+
n = exestack.ga_len / 2;
3869+
if (n < exestack.ga_growsize)
3870+
n = exestack.ga_growsize;
3871+
3872+
// Don't make it bigger though.
3873+
if (exestack.ga_len + n < exestack.ga_maxlen)
3874+
{
3875+
new_len = exestack.ga_itemsize * (exestack.ga_len + n);
3876+
pp = vim_realloc(exestack.ga_data, new_len);
3877+
if (pp == NULL)
3878+
return FAIL;
3879+
exestack.ga_maxlen = exestack.ga_len + n;
3880+
exestack.ga_data = pp;
3881+
}
3882+
}
3883+
38603884
// We advance by two because we add one for items referenced through
38613885
// previous_funccal.
38623886
copyID = get_copyID();

src/version.c

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

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
61,
745747
/**/
746748
60,
747749
/**/

0 commit comments

Comments
 (0)