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]

New Garbage Collection for Smobs


OK, I have my smobs working with the latest snapshot and I'm
not worrying about using SCM_SETGC8MARK( x ); anymore.

One problem that I was having with the old system
(and still am with the new) is that when I store a list
of substrings within my table and I go through a mark stage
where I call scm_gc_mark() on any data in the table
I get a segmentation violation in the garbage collector (!)

I still can't pin down any details more than that but
if I store the substrings directly (not in a list) then it
doesn't crash even though my code does exactly the same thing
(as soon as I get time, I'll fiddle around and get something
small that demonstrates this effect).
Are there gotchas in using (make-shared-substring) and
(substring)? They are essential for working with regexp stuff.

Something (probably unrelated) that I noticed is that
if your smob checks it's SCM_TYP16() value during garbage
collection then it will see the 0x80 flag bit and might fail
sanity checks. The safest thing is to mask out the flag bit:

static int table_is_table( SCM x )
{
	if( SCM_NIMP( x ))
	{
		long z = SCM_TYP16( x );

		z &= 0xff7f; /* clear GC8 bit */

		if( z == scm_tc16_table )
			return( 1 );
	}
	return( 0 );
}

I feel that SCM_TYP16() should mask this and suggest that it be changed.

	- Tel