diff --git a/collects/tests/racket/prompt-tests.rktl b/collects/tests/racket/prompt-tests.rktl index 47bbd5a89b..f90d533eed 100644 --- a/collects/tests/racket/prompt-tests.rktl +++ b/collects/tests/racket/prompt-tests.rktl @@ -1993,6 +1993,17 @@ (sync (thread (lambda () (k 6)))) (void))) +(test (void) + 'capture-in-transferred-thread/values + (let ([k (call-with-continuation-prompt + (lambda () + (let/ec esc + (define-values (a b) (call/cc esc)) + (+ a b) + (call/cc values))))]) + (sync (thread (lambda () (k 6 7)))) + (void))) + (let () (define sema (make-semaphore 1)) (define l null) diff --git a/src/racket/src/eval.c b/src/racket/src/eval.c index 7616b5d279..4bf80a9505 100644 --- a/src/racket/src/eval.c +++ b/src/racket/src/eval.c @@ -1520,8 +1520,9 @@ Scheme_Object *scheme_jump_to_continuation(Scheme_Object *obj, int num_rands, Sc MZ_RUNSTACK = old_runstack; return scheme_compose_continuation(c, num_rands, value); } else { - /* Aborting (Racket-style) continuation. */ + /* Aborting (Scheme-style) continuation. */ int orig_cac = scheme_continuation_application_count; + Scheme_Overflow *thread_end_oflow; scheme_about_to_move_C_stack(); @@ -1550,6 +1551,9 @@ Scheme_Object *scheme_jump_to_continuation(Scheme_Object *obj, int num_rands, Sc c->common_dw_depth = common_depth; + /* in case we need it (since no allocation allowed later): */ + thread_end_oflow = scheme_get_thread_end_overflow(); + if (num_rands == 1) c->value = value; else { @@ -1558,6 +1562,8 @@ Scheme_Object *scheme_jump_to_continuation(Scheme_Object *obj, int num_rands, Sc c->value = vals; } + /* !! No allocation or GCs allowed from here to the longjmp() !! */ + c->common_dw = common; c->common_next_meta = p->next_meta; @@ -1578,9 +1584,7 @@ Scheme_Object *scheme_jump_to_continuation(Scheme_Object *obj, int num_rands, Sc /* Prompt is pseudo-prompt at thread beginning. We're effectively composing the continuation, so use its prompt stack start. */ - Scheme_Overflow *oflow; - oflow = scheme_get_thread_end_overflow(); - c->resume_to = oflow; + c->resume_to = thread_end_oflow; p->stack_start = c->prompt_stack_start; } scheme_longjmpup(&c->buf);