summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-12-11 22:07:44 +0100
committerGitHub <noreply@github.com>2018-12-11 22:07:44 +0100
commite3d91a5b748e9871fc952b6a6bcd91a2cfca2cb2 (patch)
treecb1a6e507fed76dae7774d4e166a416e34d673e8 /lib
parent3695819018ca7c6b981313a2a7bf91b842f5207c (diff)
parent497e8c41e8a32ae96633d7a7e3011980e38f2b69 (diff)
downloadNim-e3d91a5b748e9871fc952b6a6bcd91a2cfca2cb2.tar.gz
Merge pull request #9923 from stefantalpalaru/calldepth
replace misleading "stack overflow" message when reaching Nim's call depth limit
Diffstat (limited to 'lib')
-rw-r--r--lib/system/excpt.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index a6da8f5a3..800b5cd2f 100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -454,16 +454,18 @@ when not defined(gcDestructors):
     shallowCopy(result, e.trace)
 
 when defined(nimRequiresNimFrame):
-  proc stackOverflow() {.noinline.} =
+  const nimCallDepthLimit {.intdefine.} = 2000
+
+  proc callDepthLimitReached() {.noinline.} =
     writeStackTrace()
-    showErrorMessage("Stack overflow\n")
+    showErrorMessage("Error: call depth limit reached in a debug build (" & $nimCallDepthLimit & " function calls). You can change it with -d:nimCallDepthLimit=<int> or switch to a release build with -d:release.\n")
     quitOrDebug()
 
   proc nimFrame(s: PFrame) {.compilerRtl, inl, exportc: "nimFrame".} =
     s.calldepth = if framePtr == nil: 0 else: framePtr.calldepth+1
     s.prev = framePtr
     framePtr = s
-    if s.calldepth == 2000: stackOverflow()
+    if s.calldepth == nimCallDepthLimit: callDepthLimitReached()
 else:
   proc pushFrame(s: PFrame) {.compilerRtl, inl, exportc: "nimFrame".} =
     # XXX only for backwards compatibility