guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-12-118-g3


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-12-118-g3b3518e
Date: Fri, 01 Oct 2010 15:08:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=3b3518e7f60750c878d430081358b2335df4a5da

The branch, master has been updated
       via  3b3518e7f60750c878d430081358b2335df4a5da (commit)
      from  b95d76fcf28fe2b10985daba3dff91281846f879 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3b3518e7f60750c878d430081358b2335df4a5da
Author: Andy Wingo <address@hidden>
Date:   Fri Oct 1 17:11:25 2010 +0200

    update api-debug.texi discussion of stack overflow
    
    * doc/ref/api-debug.texi (Debug Options): Update stack overflow
      discussion.

-----------------------------------------------------------------------

Summary of changes:
 doc/ref/api-debug.texi |   51 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/doc/ref/api-debug.texi b/doc/ref/api-debug.texi
index 82efd74..5be997e 100644
--- a/doc/ref/api-debug.texi
+++ b/doc/ref/api-debug.texi
@@ -342,7 +342,7 @@ you might use:
 
 (catch-all
  (lambda () (error "Not a vegetable: tomato")))
-=| Uncaught throw to 'misc-error: (#f ~A (Not a vegetable: tomato) #f)
address@hidden Uncaught throw to 'misc-error: (#f ~A (Not a vegetable: tomato) 
#f)
 @result{} #f
 @end smalllisp
 
@@ -629,14 +629,41 @@ options and switches them on, @code{debug-disable} 
switches them off.
 @cindex overflow, stack
 @cindex stack overflow
 Stack overflow errors are caused by a computation trying to use more
-stack space than has been enabled by the @code{stack} option.  They are
-reported like this:
+stack space than has been enabled by the @code{stack} option.  There are
+actually two kinds of stack that can overflow, the C stack and the
+Scheme stack.
+
+Scheme stack overflows can occur if Scheme procedures recurse too far
+deeply. An example would be the following recursive loop:
 
 @lisp
-(non-tail-recursive-factorial 500)
address@hidden
+scheme@@(guile-user)> (let lp () (+ 1 (lp)))
+<unnamed port>:8:17: In procedure vm-run:
+<unnamed port>:8:17: VM: Stack overflow
address@hidden lisp
+
+The default stack size should allow for about 10000 frames or so, so one
+usually doesn't hit this level of recursion. Unfortunately there is no
+way currently to make a VM with a bigger stack. If you are in this
+unfortunate situation, please file a bug, and in the meantime, rewrite
+your code to be tail-recursive (@pxref{Tail Calls}).
+
+The other limit you might hit would be C stack overflows. If you call a
+primitive procedure which then calls a Scheme procedure in a loop, you
+will consume C stack space. Guile tries to detect excessive consumption
+of C stack space, throwing an error when you have hit 80% of the
+process' available stack (as allocated by the operating system), or 160
+kilowords in the absence of a strict limit.
+
+For example, looping through @code{call-with-vm}, a primitive that calls
+a thunk, gives us the following:
+
address@hidden
+scheme@@(guile-user)> (use-modules (system vm vm))
+scheme@@(guile-user)> (debug-set! stack 10000)
+scheme@@(guile-user)> (let lp () (call-with-vm (the-vm) lp))
+ERROR: In procedure call-with-vm:
 ERROR: Stack overflow
-ABORT: (stack-overflow)
 @end lisp
 
 If you get an error like this, you can either try rewriting your code to
@@ -645,18 +672,10 @@ the maximum stack size, use @code{debug-set!}, for 
example:
 
 @lisp
 (debug-set! stack 200000)
address@hidden
-(show-file-name #t stack 200000 debug backtrace depth 20
-   maxdepth 1000 frames 3 indent 10 width 79 procnames cheap)
-
-(non-tail-recursive-factorial 500)
address@hidden
address@hidden
 @end lisp
 
-If you prefer to try rewriting your code, you may be able to save stack
-space by making some of your procedures @dfn{tail recursive}
-(@pxref{Tail Calls}).
+But of course it's better to have your code operate without so much
+resource consumption, avoiding loops through C trampolines.
 
 
 @node Traps


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]