From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14686 invoked by alias); 21 Jun 2005 16:49:09 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 14572 invoked by uid 22791); 21 Jun 2005 16:49:00 -0000 Received: from omnigroup.com (HELO machop.omnigroup.com) (198.151.161.1) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 21 Jun 2005 16:49:00 +0000 Received: from [198.151.161.19] (seel.omnigroup.com [198.151.161.19]) by machop.omnigroup.com (Postfix) with ESMTP id 10F0A2F0BA43; Tue, 21 Jun 2005 09:48:58 -0700 (PDT) In-Reply-To: <42B7F636.3030306@almonde.com> References: <42B7F636.3030306@almonde.com> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <54238256-76C7-4883-9B74-AA7C91070E1C@omnigroup.com> Cc: gnustep-dev@gnu.org, gcc@gcc.gnu.org Content-Transfer-Encoding: 7bit From: "Timothy J. Wood" Subject: Re: Problem implementing faults in Objective-C Date: Tue, 21 Jun 2005 16:49:00 -0000 To: Frederic Stark X-SW-Source: 2005-06/txt/msg00948.txt.bz2 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