mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
refs #24503 Infinite recursions currently are not tracked separately from infinite loops, because they also increase the loop counter. However the max infinite loop count is very high by default (10 million) and does not reliably catch infinite recursions before consuming a lot of memory. So to protect against infinite recursions, we separately track call depth, and add a separate option for the maximum call depth, much lower than the maximum iteration count by default (2000, the same as `nimCallDepthLimit`). --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
10 lines
259 B
Nim
10 lines
259 B
Nim
proc foo(x: int) =
|
|
if x < 0:
|
|
echo "done"
|
|
else:
|
|
foo(x + 1) #[tt.Error
|
|
^ maximum call depth for the VM exceeded; if you are sure this is not a bug in your code, compile with `--maxCallDepthVM:number` (current value: 2000)]#
|
|
|
|
static:
|
|
foo(1)
|