bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Latent bugs?


From: Lynn Winebarger
Subject: Re: Latent bugs?
Date: Sat, 28 Dec 2002 04:30:35 -0500

On Saturday 28 December 2002 03:49, Marko Rauhamaa wrote:
> The Guile manual warns about "a Common Mistake in Allocating Smobs":
> 
> http://www.gnu.org/software/guile/docs/guile-ref/A-Common-Mistake-In-Allocating-Smobs.html#A%20Common%20Mistake%20In%20Allocating%20Smobs
> 
> Indeed, it seems to me the Guile 1.6.0 source code contains numerous
> instances of this common mistake. For example (in scmsigs.c):
> 
>   return scm_list_2(scm_cons(scm_long2num(old_timer.it_interval.tv_sec),
>                              scm_long2num(old_timer.it_interval.tv_usec)),
>                     scm_cons(scm_long2num(old_timer.it_value.tv_sec),
>                              scm_long2num(old_timer.it_value.tv_usec)));
> 
> If I understand it correctly, this statement contains several
> allocations, each of which can potentially trigger garbage collection
> and delete any of the intermediate results.
> 
> Have I mistaken? What is the right way of constructing and returning the
> list above?
> 
      I believe you are mistaken.  The web page you cite gives an example
of a newly created object whose only references are contained in a structure
in a heap that isn't known to the garbage collector. 
     The code above, though it is not explicit, will store the intermediate 
return 
values (references)  on the stack, where the garbage collector will see them
(and thus not free the newly created object).  It's just how the traditional
model of a C machine works.

Lynn




reply via email to

[Prev in Thread] Current Thread [Next in Thread]