This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Why does the GC frees my function?
Dimitri Ara <dimitri.ara@mail.dotcom.fr> writes:
> init_hook = scm_make_named_hook ("init", 1);
>
> and i add a function to it:
>
> (add-hook! init
> (lambda (str)
> (display
> (string-append "Welcome to " str ".\n"))))
>
> and then, when i run the hook, guile yalles at me:
>
> ERROR: In procedure string-append:
> ERROR: Wrong type argument: #<freed cell 0x401946b8; GC missed a reference>
It's documented... somewhere. :) GC will scan the variables on the C
stack but static and global ones. What you want to do is to call
scm_gc_protect(init_hook) after you create it.
--
How to eff the ineffable?