This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Problem implementing faults in Objective-C
- From: "Timothy J. Wood" <tjw at omnigroup dot com>
- To: Frederic Stark <gsfred at almonde dot com>
- Cc: gnustep-dev at gnu dot org, gcc at gcc dot gnu dot org
- Date: Tue, 21 Jun 2005 09:48:56 -0700
- Subject: Re: Problem implementing faults in Objective-C
- References: <42B7F636.3030306@almonde.com>
On Jun 21, 2005, at 4:12 AM, Frederic Stark wrote:
I am sending this to gnustep-dev crossposted to gcc. Maybe this
isn't the right mailing list. See at the end of the post for a 40
line program that exhibit the bad behavior.
Problem:
If a is a fault (ie: changes its isa pointer during
forwardInvocation), then:
[a method1:[a method2]]
fails (a does not recognize 'method1:'), while:
I believe the GNU runtime looks up the IMP and then calls it
rather than always calling a dispatch function. In this case, the
code above is possibly getting miscompiled into something like
IMP imp1 = getInstanceImp(a->isa, @selector(method1:))
IMP imp2 = getInstanceImp(a->isa, @selector(method2))
id result1 = imp2(a, @selector(method2))
id result2 = imp1(a, @selector(method1:), result1)
That is, the lookup of the IMP for -method1: may be happening too
early.
The code works correctly under Mac OS X.
The Apple runtime doesn't have this design choice, so it can't
really have this problem.
Am I doing something horribly wrong ?
I don't think so; seems like a bug in the GNU ObjC runtime support
in the compiler. I suppose the runtime maintainers might choose to
define this as a bug in your code, but isa-swizzling is a fairly
common and _extremely_ useful pattern in ObjC (see CoreData,
NSZombie, etc.) so that'd not be my stance, obviously :)
-tim