This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Why does the GC frees my function?


Dimitri Ara <dimitri.ara@mail.dotcom.fr> writes:

> Miroslav Silovic <silovic@zesoi.fer.hr> a écrit :
> 
> > > Hum, I didn't found any function named scm_gc_protect. I tried with
> > > other function like scm_gc_mark ou scm_object_protect but it doesn't
> > > work.
> > 
> > scm_protect_object.
> 
> I allready tried this one and it doesn't work. It seems that the
> problem is not my hook but the lambda function added to it. As a
> matter of fact, it seems that init_hook is not freed:
> 
> 107       run_hook1 (init_hook, version); 
> (gdb) p *init_hook
> $5 = 66943
> (gdb) n
> ERROR: In procedure string-append:
> ERROR: Wrong type argument: #<freed cell 0x401946b8; GC missed a reference>
> 
> (add-hook! init
>  	   (lambda (str)
> 	     (display
> 	      (string-append "Welcome to " str ".\n"))))
> 
> One of the operand of string-append is freed?

Give this a try, and see if it fixes your problem:

Index: feature.c
===================================================================
RCS file: /cvs/guile/guile/guile-core/libguile/feature.c,v
retrieving revision 1.31
diff -c -c -r1.31 feature.c
*** feature.c	2000/01/11 23:56:47	1.31
--- feature.c	2000/02/28 02:39:56
***************
*** 163,172 ****
  scm_create_hook (const char* name, int n_args)
  {
    SCM vcell = scm_sysintern0 (name);
!   SCM hook = make_hook (SCM_CAR (vcell), SCM_MAKINUM (n_args),
  			"scm_create_hook");
    SCM_SETCDR (vcell, hook);
-   scm_protect_object (vcell);
    return hook;
  }
  
--- 163,173 ----
  scm_create_hook (const char* name, int n_args)
  {
    SCM vcell = scm_sysintern0 (name);
!   SCM hook;
!   scm_protect_object (vcell);
!   hook = make_hook (SCM_CAR (vcell), SCM_MAKINUM (n_args),
  			"scm_create_hook");
    SCM_SETCDR (vcell, hook);
    return hook;
  }
  


-- 
Gregh

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]