summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-04-17 09:27:32 +0200
committerAndy Wingo <wingo@pobox.com>2009-04-17 09:27:32 +0200
commit798244609bfd3b4d2b12f722d9130d47abcfeb1a (patch)
treeb3ab0a6f78afac769a323178f82e67cf5782f1a7
parentb8076ec6cc3a18a92186d954684f88a735a42018 (diff)
downloadguile-798244609bfd3b4d2b12f722d9130d47abcfeb1a.tar.gz
fix a couple gc-related continuations bugs
Thanks to Juhani Rantanen for the report. * libguile/continuations.c (scm_make_continuation): Delay making the smob until the data is fully initialized. Fixes a bug whereby a GC in scm_vm_capture_continuations would catch the us with an undefined continuation->vm_conts, leading to marking badness. * libguile/vm.c (vm_cont_free): Report the correct size to scm_gc_free.
-rw-r--r--libguile/continuations.c4
-rw-r--r--libguile/vm.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/libguile/continuations.c b/libguile/continuations.c
index 2b10126cf..dc1456985 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -121,8 +121,6 @@ scm_make_continuation (int *first)
continuation->root = thread->continuation_root;
continuation->dframe = scm_i_last_debug_frame ();
src = thread->continuation_base;
- SCM_NEWSMOB (cont, scm_tc16_continuation, continuation);
-
#if ! SCM_STACK_GROWS_UP
src -= stack_size;
#endif
@@ -130,6 +128,8 @@ scm_make_continuation (int *first)
memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size);
continuation->vm_conts = scm_vm_capture_continuations ();
+ SCM_NEWSMOB (cont, scm_tc16_continuation, continuation);
+
*first = !setjmp (continuation->jmpbuf);
if (*first)
{
diff --git a/libguile/vm.c b/libguile/vm.c
index 4314a6847..38d085c99 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -136,7 +136,7 @@ vm_cont_free (SCM obj)
struct scm_vm_cont *p = SCM_VM_CONT_DATA (obj);
scm_gc_free (p->stack_base, p->stack_size * sizeof (SCM), "stack-base");
- scm_gc_free (p, sizeof (struct scm_vm), "vm");
+ scm_gc_free (p, sizeof (*p), "vm-cont");
return 0;
}