guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-118-g70057


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-118-g70057f3
Date: Thu, 05 Dec 2013 21:19:08 +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=70057f3408f8bb469941fa3ab497076ec8f2a117

The branch, stable-2.0 has been updated
       via  70057f3408f8bb469941fa3ab497076ec8f2a117 (commit)
      from  e54c7dd67cd299e248c544caf330587915cc95a0 (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 70057f3408f8bb469941fa3ab497076ec8f2a117
Author: Ludovic Courtès <address@hidden>
Date:   Thu Dec 5 22:18:02 2013 +0100

    vm: Gracefully handle stack overflows.
    
    Fixes <http://lists.gnu.org/archive/html/guile-user/2013-12/msg00017.html>.
    Reported by address@hidden (R. Clayton).
    
    * libguile/vm.c (reinstate_stack_reserve): New function.
      (vm_error_stack_overflow): Install it as an unwind handler.
    * test-suite/tests/control.test ("the-vm")["stack overflow reinstates
      stack reserve"]: New test.

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

Summary of changes:
 libguile/vm.c                 |   15 +++++++++++++++
 test-suite/tests/control.test |   15 ++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/libguile/vm.c b/libguile/vm.c
index 62c1d6d..d4c8b5f 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -505,6 +505,15 @@ vm_error_wrong_type_apply (SCM proc)
              scm_list_1 (proc), scm_list_1 (proc));
 }
 
+/* Reinstate the stack reserve in the VM pointed to by DATA.  */
+static void
+reinstate_stack_reserve (void *data)
+{
+  struct scm_vm *vp = data;
+
+  vp->stack_limit -= VM_STACK_RESERVE_SIZE;
+}
+
 static void
 vm_error_stack_overflow (struct scm_vm *vp)
 {
@@ -516,7 +525,13 @@ vm_error_stack_overflow (struct scm_vm *vp)
     /* There is no space left on the stack.  FIXME: Do something more
        sensible here! */
     abort ();
+
+  /* Before throwing, install a handler that reinstates the reserve so
+     that subsequent overflows are gracefully handled.  */
+  scm_dynwind_begin (0);
+  scm_dynwind_unwind_handler (reinstate_stack_reserve, vp, 0);
   vm_error ("VM: Stack overflow", SCM_UNDEFINED);
+  scm_dynwind_end ();
 }
 
 static void
diff --git a/test-suite/tests/control.test b/test-suite/tests/control.test
index 5b292c4..0d95dba 100644
--- a/test-suite/tests/control.test
+++ b/test-suite/tests/control.test
@@ -375,7 +375,20 @@
         (lambda (key vm)
           (and (eq? key 'foo)
                (eq? vm new-vm)
-               (eq? (the-vm) prev-vm)))))))
+               (eq? (the-vm) prev-vm))))))
+
+  (pass-if "stack overflow reinstates stack reserve"
+    ;; In Guile <= 2.0.9, only the first overflow would be gracefully
+    ;; handle; subsequent overflows would lead to an abort.  See
+    ;; <http://lists.gnu.org/archive/html/guile-user/2013-12/msg00017.html>.
+    (letrec ((foo (lambda () (+ 1 (foo)))))
+      (define (overflows?)
+        (catch 'vm-error foo
+          (lambda (key proc msg . rest)
+            (and (eq? 'vm-run proc)
+                 (->bool (string-contains msg "overflow"))))))
+
+      (and (overflows?) (overflows?) (overflows?)))))
 
 ;; These tests from Oleg Kiselyov's delim-control-n.scm, available at
 ;; http://okmij.org/ftp/Scheme/delim-control-n.scm.  Public domain.


hooks/post-receive
-- 
GNU Guile



reply via email to

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