From 828848811dc732f367ba16ac40396f4ac2436704 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 25 Nov 2011 07:04:00 -0700 Subject: [PATCH] fix GC bug in futures when a blocking result is a tail call --- src/racket/src/future.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/racket/src/future.c b/src/racket/src/future.c index cc17312c38..8fda0eb14f 100644 --- a/src/racket/src/future.c +++ b/src/racket/src/future.c @@ -2787,6 +2787,17 @@ static void send_special_result(future_t *f, Scheme_Object *retval) f->num_tail_rands = p->ku.apply.tail_num_rands; p->ku.apply.tail_rator = NULL; p->ku.apply.tail_rands = NULL; + + if (p->ku.apply.tail_rands == p->tail_buffer) { + /* This only happens in the runtime thread; we need to + disconnect the tail buffer from `f->tail_rands' in + case of a GC. Beware that XFORM is disabled here. */ + Scheme_Object **tb; + p->tail_buffer = NULL; /* so args aren't zeroed */ + tb = MALLOC_N(Scheme_Object *, p->tail_buffer_size); + p = scheme_current_thread; /* in case GC moves the thread */ + p->tail_buffer = tb; + } } }