[interp] reclaim stack fragments when not used. (#32022)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Tue, 11 Feb 2020 09:59:43 +0000 (04:59 -0500)
committerGitHub <noreply@github.com>
Tue, 11 Feb 2020 09:59:43 +0000 (10:59 +0100)
commitf496497de42b80b6d031d5de445ec74b2b01bb17
tree27288118d9e5cac2134391aeadece34c539163d6
parent52cea427575f9874096c204bac0cdbf91a5a8f02
[interp] reclaim stack fragments when not used. (#32022)

When a requested frame size doesn't fit in an already allocated stack fragment, we instead allocate another, larger fragment.
When doing this we missed to free the existing stack fragment, and in combination with a second problem (`current->next` not being cleared when unused) it can accumulate to a lot of unused stack fragments and in worst-case to OOM, as it happened on Linux corlib xunit tests.

Thanks to Jay for tracking it down.

Co-authored-by: Bernhard Urban-Forster <bernhard.urban@xamarin.com>
src/mono/mono/mini/interp/interp-internals.h
src/mono/mono/mini/interp/interp.c