[Top][All Lists]

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

Re: Goops & Valgrind

From: Neil Jerram
Subject: Re: Goops & Valgrind
Date: Thu, 11 Sep 2008 23:06:57 +0200

2008/8/18 Andy Wingo <address@hidden>:
> Hi Han-Wen,
> On Fri 15 Aug 2008 22:15, Han-Wen Nienhuys <address@hidden> writes:
>> Running the test suite through valgrind, I get some fishy errors.
>> Can someone shed a light on this?  The culprit seems to be
>> #define SCM_NUMBER_OF_SLOTS(x) \
>>  ((SCM_STRUCT_DATA (x)[scm_struct_i_n_words]) - scm_struct_n_extra_words)
>> where scm_struct_i_n_words is -2

Reading somewhat belatedly through this trail...

Up until your email, I was thinking that the problem here is the "-
scm_struct_n_extra_words" - i.e. Mikael's error #2.  It seems clear
from the code in scm_alloc_struct() that SCM_STRUCT_DATA
(x)[scm_struct_i_n_words] does not include the extra words, and hence
that scm_struct_n_extra_words should not be subtracted.

But then you wrote....

> 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.

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?


reply via email to

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