fix space-safety bug in composable continuations

This commit is contained in:
Matthew Flatt 2011-10-29 09:33:26 -06:00
parent 007927892b
commit d9b9cbe16a
3 changed files with 31 additions and 0 deletions

View File

@ -118,6 +118,32 @@
(eval r)
(loop))))))))
;; ----------------------------------------
;; Check that a constant-space loop doesn't
;; accumulate memory (test by Nicolas Oury)
(let ()
(define prompt1 (make-continuation-prompt-tag 'p1))
(define prompt2 (make-continuation-prompt-tag 'p2))
(define (capture-and-abort prompt-tag)
(call-with-composable-continuation
(lambda (k) (abort-current-continuation prompt-tag k))
prompt-tag))
(define (go i)
(call-with-continuation-prompt
(lambda ()
(call-with-continuation-prompt
(lambda()
(for ((j i))
(capture-and-abort prompt1)
(capture-and-abort prompt2)))
prompt2))
prompt1))
(test (void) go 100000))
;; ----------------------------------------
(report-errs)

View File

@ -6256,6 +6256,9 @@ Scheme_Object *scheme_compose_continuation(Scheme_Cont *cont, int num_rands, Sch
empty_to_next_mc = 0;
}
/* Clear to avoid retaining a chain of meta-continuationss: */
mc = NULL;
value = compose_continuation(cont, 0, NULL, empty_to_next_mc);
scheme_current_thread->next_meta -= 1;

View File

@ -395,9 +395,11 @@ char *scheme_get_type_name(Scheme_Type t)
if (t < 0 || t >= maxtype)
return "<bad-value>";
s = type_names[t];
#ifndef MZ_GC_BACKTRACE
if (!s)
return "???";
else
#endif
return s;
}