From acbfb5946b783c8782e1f36d183e896b18fcb5f6 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Sun, 21 Oct 2007 20:43:14 +0000 Subject: [PATCH 1/1] (unmemoize_delay): Extend the environment before unmemoizing the promise thunk. This fixes a segmentation fault reported by Frank Schwidom. --- libguile/ChangeLog | 6 ++++++ libguile/eval.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 691159b52..854a3651f 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2007-10-21 Neil Jerram + + * eval.c (unmemoize_delay): Extend the environment before + unmemoizing the promise thunk. This fixes a segmentation fault + reported by Frank Schwidom. + 2007-10-20 Julian Graham Add support for thread cancellation and user-defined thread diff --git a/libguile/eval.c b/libguile/eval.c index 8d6c4d923..f129df6fb 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -1268,7 +1268,13 @@ static SCM unmemoize_delay (const SCM expr, const SCM env) { const SCM thunk_expr = SCM_CADDR (expr); - return scm_list_2 (scm_sym_delay, unmemoize_expression (thunk_expr, env)); + /* A promise is implemented as a closure, and when applying a + closure the evaluator adds a new frame to the environment - even + though, in the case of a promise, the added frame is always + empty. We need to extend the environment here in the same way, + so that any ILOCs in thunk_expr can be unmemoized correctly. */ + const SCM new_env = SCM_EXTEND_ENV (SCM_EOL, SCM_EOL, env); + return scm_list_2 (scm_sym_delay, unmemoize_expression (thunk_expr, new_env)); } -- 2.20.1