On 27-Jun-09, at 10:29 PM, lowly coder wrote:
I understand the when I get a heapoverflow, gambit can't pop me into a REPL (since that'll take more heap).
That's not true. The heap management was designed to trigger a "heap overflow" exception before the heap is completely full. A space called the "heap overflow reserve" is set aside and when there is a (non-fatal) heap overflow, a large part of this space is given back to the heap so that the debugger (which is written in Scheme) can still do its work. A subsequent heap overflow will give back a large part of what's left of the new heap overflow reserve, and so on. When the heap overflow reserve is insufficient to run the exception handler (or the REPL that it starts) then a "fatal heap overflow" terminates the program.
However, can I get a dying process to print out a backtrace for me? (Increasing the maximum heap size won't solve this problem -- the problem is that I have some run away code that is consuming up all the memory, and if I increase the max heap size, all that happens is that it just makes it longer to heap overflow).
[I debugged the last one manually by trying pieces of code here & there; but if I could get a backtrace, it'd just be so much faster]
Do you get something like this?
% gsi -:h10000 Gambit v4.4.4
(define (f n) (let ((v (make-vector 5))) (cons v (f (+ n 1))))) (f 0)
*** ERROR IN f, (console)@1.50 -- Heap overflow 1> ,be 0 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47825 1 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47824 2 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47823 3 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47822 4 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47821 5 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47820 6 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47819 7 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47818 8 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47817 9 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 47816 ... 47823 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 2 47824 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 1 47825 f (console)@1:50 (f (+ n 1)) v = '#(0 0 0 0 0) n = 0 47826 (interaction) (console)@2:1 (f 0) 1>
Marc