diff options
author | Araq <rumpf_a@web.de> | 2014-04-05 21:05:07 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-04-05 21:05:07 +0200 |
commit | 4835199125415dbd40d863ea945a71bab9b6962b (patch) | |
tree | 9ea5037574f59b89b4490bf622aae7603600db63 /compiler | |
parent | 033f2bbbf267cd4fe4f2567aca8aa7483201a737 (diff) | |
download | Nim-4835199125415dbd40d863ea945a71bab9b6962b.tar.gz |
new VM: proper shield against endless recursions
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/vm.nim | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim index b365dba9a..fb8749250 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -48,9 +48,17 @@ type # XXX 'break' should perform cleanup actions # What does the C backend do for it? -proc stackTraceAux(c: PCtx; x: PStackFrame; pc: int) = +proc stackTraceAux(c: PCtx; x: PStackFrame; pc: int; recursionLimit=100) = if x != nil: - stackTraceAux(c, x.next, x.comesFrom) + if recursionLimit == 0: + var calls = 0 + var x = x + while x != nil: + inc calls + x = x.next + msgWriteln($calls & " calls omitted\n") + return + stackTraceAux(c, x.next, x.comesFrom, recursionLimit-1) var info = c.debug[pc] # we now use the same format as in system/except.nim var s = toFilename(info) |