summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authoryatsen1 <kitech@sixlan.tk>2020-09-18 23:17:09 +0800
committerGitHub <noreply@github.com>2020-09-18 17:17:09 +0200
commit341cd844b282cc6ed3b1fc4c1ef10c38fc06d5e7 (patch)
tree151533e9e12bd39f9302a3019983c8f603e182c7 /lib/system
parentd19316bbb986a7dd1d6d091173963f6e74c65991 (diff)
downloadNim-341cd844b282cc6ed3b1fc4c1ef10c38fc06d5e7.tar.gz
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>
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/gc_common.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/system/gc_common.nim b/lib/system/gc_common.nim
index 7f6c41e1b..658c5d025 100644
--- a/lib/system/gc_common.nim
+++ b/lib/system/gc_common.nim
@@ -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.}