guile-devel
[Top][All Lists]
Advanced

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

Re: Goops & Valgrind


From: Andy Wingo
Subject: Re: Goops & Valgrind
Date: Fri, 12 Sep 2008 21:22:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

On Thu 11 Sep 2008 23:06, "Neil Jerram" <address@hidden> writes:

>> Classes that are not metaclasses allocate their instances using "light
>> structs". So the object layout goes like this:
>>
>>                     the vtable word               the data word
>>                +-------------------------------+---------------------+
>> SCM of object = |SCM of class | scm_tc3_struct  | SCM* array of slots |
>>                +-------------------------------|---------------------+
>>
>> For classes, the SCM* points to the middle of a SCM array, which has
>> some number of words before 0; 4 words normally, or 6 if the object is
>> an "entity", like a generic function. But for objects there are no words
>> before 0, hence the valid valgrind error.
>
> Are you sure?  Surely that would require a call somewhere to
> scm_alloc_struct() with n_extra = 0, and I can't see any of those.

I'm sure -- goops.c:1541 in master. Doesn't go through scm_alloc_struct
at all.

> Also, is Mikael right with his error #1?  I'm thinking not, because I
> believe that instances are structs too, so surely it's OK to call
> SCM_STRUCT_DATA (x)[...] on them?

I can't recall the mail at the moment. Please reply if you want me to
dig through this -- I'm happy to do so. But instances are structs, yes.
Calling SCM_STRUCT_DATA (x)[] does work. You have to know how many
fields there are, though -- you get that from the vtable.

Andy
-- 
http://wingolog.org/




reply via email to

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