diff --git a/collects/tests/racket/basic.rktl b/collects/tests/racket/basic.rktl index 9557d62ebb..5600db4f3c 100644 --- a/collects/tests/racket/basic.rktl +++ b/collects/tests/racket/basic.rktl @@ -1836,6 +1836,19 @@ ((car x) (lambda () x)) (pair? (x))))) +;; Check shared escape continuation of nested call/cc: +(let ([ch (make-channel)]) + (thread + (lambda () + (channel-put + ch + (call/cc + (lambda (escape) + (call/cc + (lambda (escape1) + (escape1 3)))))))) + (sync ch)) + (arity-test call/cc 1 2) (arity-test call/ec 1 1) (err/rt-test (call/cc 4)) diff --git a/src/racket/src/fun.c b/src/racket/src/fun.c index b812d5b540..9f1b61a844 100644 --- a/src/racket/src/fun.c +++ b/src/racket/src/fun.c @@ -6181,7 +6181,7 @@ internal_call_cc (int argc, Scheme_Object *argv[]) && (sub_cont->prompt_tag == prompt_tag) && (sub_cont->barrier_prompt == effective_barrier_prompt) && (((Scheme_Escaping_Cont *)sub_cont->escape_cont)->myerr == p->error_buf)) { - /* Whether sub_cont turns out to be the same continuaiton, we can use + /* Whether sub_cont turns out to be the same continuation, we can use its escape continuation, because jumping to the escape continuation triggers the same C-level clean-up actions, same `dynamic-wind's, and crosses the same continuation barriers. */ @@ -6230,10 +6230,10 @@ internal_call_cc (int argc, Scheme_Object *argv[]) cont = MALLOC_ONE_TAGGED(Scheme_Cont); cont->so.type = scheme_cont_type; cont->buf.cont = sub_cont; - sub_cont = sub_cont->buf.cont; - cont->escape_cont = sub_cont->escape_cont; + sub_cont = sub_cont->buf.cont; + /* This mark stack won't be restored, but it may be used by `continuation-marks'. */ cont->ss.cont_mark_stack = MZ_CONT_MARK_STACK;