diff options
Diffstat (limited to 'src/runtime/stack.c')
| -rw-r--r-- | src/runtime/stack.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/stack.c b/src/runtime/stack.c index b38ee31d48..95a5a123d9 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -806,8 +806,16 @@ runtime·shrinkstack(G *gp) { uintptr used, oldsize, newsize; - if(runtime·readgstatus(gp) == Gdead) + if(runtime·readgstatus(gp) == Gdead) { + if(gp->stack.lo != 0) { + // Free whole stack - it will get reallocated + // if G is used again. + runtime·stackfree(gp->stack); + gp->stack.lo = 0; + gp->stack.hi = 0; + } return; + } if(gp->stack.lo == 0) runtime·throw("missing stack in shrinkstack"); |
