fix coro proc crash for stack problem when run long enough than a GC cycle (#7612) (#11410)

Co-authored-by: drswinghead <drswinghead@gmail.com>
Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
yatsen1 2020-09-18 23:17:09 +08:00 • committed by GitHub
commit 341cd844b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -273,6 +273,9 @@ when nimCoroutines:
gch.activeStack = gch.stack.find(bottom)
gch.activeStack.setPosition(addr(sp))
proc GC_getActiveStack() : pointer {.cdecl, exportc.} =
return gch.activeStack.bottom
when not defined(useNimRtl):
proc nimGC_setStackBottom(theStackBottom: pointer) =
# Initializes main stack of the thread.
@ -300,6 +303,9 @@ when not defined(useNimRtl):
else:
gch.stack.bottom = cast[pointer](max(a, b))
when nimCoroutines:
if theStackBottom != nil: gch.stack.bottom = theStackBottom
gch.stack.setPosition(theStackBottom)
{.pop.}