diff options
author | Ștefan Talpalaru <stefantalpalaru@yahoo.com> | 2018-12-10 17:59:07 +0100 |
---|---|---|
committer | Ștefan Talpalaru <stefantalpalaru@yahoo.com> | 2018-12-10 19:35:37 +0100 |
commit | 497e8c41e8a32ae96633d7a7e3011980e38f2b69 (patch) | |
tree | 3933287a0e99f18c497d09875375d9017bd670be /lib/system | |
parent | cd81f368d184dae6268ccf5f4bdc771a661f4ac1 (diff) | |
download | Nim-497e8c41e8a32ae96633d7a7e3011980e38f2b69.tar.gz |
replace misleading "stack overflow" message on call depth limit
The new error message looks like this: "Error: call depth limit reached in a debug build (2000 function calls). You can change it with -d:nimCallDepthLimit=<int> or switch to a release build with -d:release."
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/excpt.nim | 8 |
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 |