fix problem with continuations
The problem was a misplaced allocation that could cause a GC when the thread is in an unstable state in the process of applying a continuation.
This commit is contained in:
parent
249c1cc666
commit
70ab6d482a
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user