1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

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.
This commit is contained in:
Andy Wingo 2009-04-17 09:27:32 +02:00
parent b8076ec6cc
commit 798244609b
2 changed files with 3 additions and 3 deletions

View file

@ -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)
{

View file

@ -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;
}