This is the mail archive of the guile@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]

A GC problem.



[ Disclaimer: I may be wrong, and the problem may be a much
  simpler bug that I just can't find ].

The problem.
~~~~~~~~~~~~

I've implemented (modulo the GC bug I'm discussing here) a
quite sophisticated record facility for Guile (yeah, so I finally
got to it :).

A record is (currently) a smob that contains, among other data,
an SCM value representing a record type descriptor for this record
(which is another smob).

As the records are quite flexible, they let the user specify a
custom free procedure (just like smobs do).

Now, such customization is of course made to record types, not
individual records.

So we have the following situation: the free procedure for a record
is contained in it's type descriptor.  If the record was the last
object to reference the descriptor, than the descriptor will be
considered good for freeing too.

My bug manifests itself as a segfault in the records's smob free
procedure, when I try to retrieve the custom free procedure from
the descriptor.

My guess is that sometimes the descriptor is deallocated *before*
the record, as the garbage collector couldn't care less about my
order dependencies.

The question.
~~~~~~~~~~~~~

1. Does my guess look right?

2. If so, what can I do to prevent descriptors being collected
before the records?

3. If I'm wrong, do you have some debugging tips?

Thanks a lot,
mike.