Hello all, I've just tried to compile the svn tree on my 64bit machine and ran into the following issue: The ETObjectMirror class in the new reflection code uses the address of the object it is mirroring as its hash. Unfortunately the unsigned int to which the pointer is cast will cause it to be truncated, possibly causing collisions between the hashes of mirrors of unrelated objects.
Unfortunately, GNUstep has not yet made the switch to the Mac OS 10.5-style definition of NSUInteger, which would just make this a non-issue because it would always be sized properly. I've attached a little workaround, which will use the hash of the object if available and only fall back to the address otherwise. This way, the truncation will only be a problem if you are on 64bit, have more than 4GB RAM, and the object does not conform to NSObject, which should be quite rare. I just wanted to check back prior to commiting that there isn't some rationale behind not using -hash at this place. Cheers, Niels
Index: ETReflection.m =================================================================== --- ETReflection.m (revision 4878) +++ ETReflection.m (working copy) @@ -341,7 +341,20 @@ } - (unsigned int) hash { - return (unsigned int) _object; + // Use the object's hash if available + if ([_object respondsToSelector: @selector(hash)]) + { + return [_object hash]; + } + + //Otherwise, use the object's address. + + /* + * FIXME: This operation will result in a truncation of the pointer on 64bit + * systems. Until GNUstep makes the transition to the Mac OS 10.5 definition + * of NSUInteger, this is typed as uintptr_t to prevent a compiler warning. + */ + return (uintptr_t) _object; } - (id <ETClassMirror>) classMirror {
_______________________________________________ Etoile-dev mailing list Etoile-dev@gna.org https://mail.gna.org/listinfo/etoile-dev