diff --git a/pkgs/racket-test-core/tests/racket/chaperone.rktl b/pkgs/racket-test-core/tests/racket/chaperone.rktl index 0ad8518824..e43bfbb3f2 100644 --- a/pkgs/racket-test-core/tests/racket/chaperone.rktl +++ b/pkgs/racket-test-core/tests/racket/chaperone.rktl @@ -2474,6 +2474,27 @@ (test-wrapped wrapped-f) (test-wrapped wrapped2-f)) +;; ---------------------------------------- +;; Check that continuation-mark depth is handled +;; properly when the JIT has to take a slow +;; path for a tail call + +(let () + (define (counter) + (let ([c 0]) + (case-lambda + [() c] + [(x) (when (= c 1) (error 'fail)) (set! c (+ c 1)) #t]))) + + (for ([i 1000]) + (let ([c (counter)]) + (letrec ([f + (contract (-> any/c c) + (λ ([x #f]) (if (zero? x) x (f (- x 1)))) + 'pos + 'neg)]) + (f 6))))) + ;; ---------------------------------------- (report-errs) diff --git a/racket/src/racket/src/fun.c b/racket/src/racket/src/fun.c index 70b30c6440..8e8aff8c83 100644 --- a/racket/src/racket/src/fun.c +++ b/racket/src/racket/src/fun.c @@ -3732,7 +3732,7 @@ static Scheme_Object *_apply_native(Scheme_Object *obj, int num_rands, Scheme_Ob obj = data->start_code(obj, num_rands, rands EXTRA_NATIVE_ARGUMENT); if (obj == SCHEME_TAIL_CALL_WAITING) - obj = force_values(obj, 1); + obj = scheme_force_value_same_mark(obj); MZ_CONT_MARK_STACK = old_cont_mark_stack; MZ_CONT_MARK_POS -= 2;