diff --git a/collects/tests/mzscheme/prompt-tests.ss b/collects/tests/mzscheme/prompt-tests.ss index 243282a59c..a6579834ee 100644 --- a/collects/tests/mzscheme/prompt-tests.ss +++ b/collects/tests/mzscheme/prompt-tests.ss @@ -1673,21 +1673,27 @@ ;; implicit prompt in the calling thread. (let () - (define (foo thunk) - (call-with-continuation-prompt - (lambda () - (let/cc ret - (let ([run? #f]) - (let/cc run - (thread (lambda () - (sync (system-idle-evt)) - (set! run? #t) - (run)))) - (when run? (ret (thunk)))))))) - (define s (make-semaphore)) - (foo (lambda () (semaphore-post s))) - (test s sync s)) - + (define (go wrap) + (let () + (define (foo thunk) + (call-with-continuation-prompt + (lambda () + (wrap + (lambda () + (let/cc ret + (let ([run? #f]) + (let/cc run + (thread (lambda () + (sync (system-idle-evt)) + (set! run? #t) + (run)))) + (when run? (ret (thunk)))))))))) + (define s (make-semaphore)) + (foo (lambda () (semaphore-post s))) + (test s sync s))) + (go (lambda (f) (f))) + (go (lambda (f) (dynamic-wind void f void)))) + ;; ---------------------------------------- ;; Try long chain of composable continuations diff --git a/src/mzscheme/src/fun.c b/src/mzscheme/src/fun.c index e130313d1f..0696a6e358 100644 --- a/src/mzscheme/src/fun.c +++ b/src/mzscheme/src/fun.c @@ -4564,11 +4564,13 @@ static void restore_continuation(Scheme_Cont *cont, Scheme_Thread *p, int for_pr p->dw = common_dw; p->next_meta = common_next_meta; if (p->dw) { /* can be empty if there's only the pseudo-prompt */ + /* also, there may be no dw with prompt_tag if there's only the pseudo prompt */ all_dw = clone_dyn_wind(p->dw, cont->prompt_tag, -1, NULL, 1, 0); - for (dw = all_dw; !SAME_OBJ(dw->prompt_tag, cont->prompt_tag); dw = dw->prev) { + for (dw = all_dw; dw && !SAME_OBJ(dw->prompt_tag, cont->prompt_tag); dw = dw->prev) { p->dw = p->dw->prev; } - dw->next_meta += 1; + if (dw) + dw->next_meta += 1; p->dw = all_dw; } }