incubator-lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marvin Humphrey (JIRA)" <>
Subject [jira] Updated: (LUCY-89) Tighten Clownfish method invocation type checking
Date Fri, 25 Dec 2009 01:27:29 GMT


Marvin Humphrey updated LUCY-89:

    Attachment: fallout.diff

The second patch, "fallout.diff", deals with the fallout from the first patch,
addressing all the new compiler warnings.

Since the C compiler can't tell that e.g. Hash inherits from Obj,
modifications such as these are necessary:

-    Obj_Dec_RefCount(hash);
+    Hash_Dec_RefCount(hash);

I only found one instance of an inappropriate method invocation in the Lucy
code base, where a Hash method was being invoked on a ZombieCharBuf in a test

-    ASSERT_TRUE(batch, Hash_Equals(&foo, Hash_Fetch(hash, (Obj*)&forty)),
+    ASSERT_TRUE(batch, ZCB_Equals(&foo, Hash_Fetch(hash, (Obj*)&forty)),

This turns out to be harmless because both Hash and ZombieCharBuf inherit the
Equals() method from Obj, so it resides at the same offset in both VTables.

However, I think it's inevitable that without the improved type checking,
future contributors to Lucy would have have been bitten at some point.  Since
function pointers with completely different signatures may reside at the same
offset in different VTables, the result would be severe: most often, a memory

> Tighten Clownfish method invocation type checking
> -------------------------------------------------
>                 Key: LUCY-89
>                 URL:
>             Project: Lucy
>          Issue Type: Improvement
>          Components: Clownfish, Core, Perl bindings
>            Reporter: Marvin Humphrey
>            Assignee: Marvin Humphrey
>         Attachments: fallout.diff, tighten_types.diff
> Clownfish method invocation is implemented using C static inline functions. 
> The first argument to these functions is the object itself, which up till now 
> has been cast to "const void*".  It is better to have the first argument match 
> the type of the invoker, so that the C compiler will issue warnings if you try 
> to invoke a method on an inappropriate object, e.g. "PriQ_Pop(hash)".

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message