Given this small Objective-C program:

<SNIP>

#include <objc/Protocol.h>

@protocol a

- aMethod;

@end


@protocol b <a>

- bMethod;

@end


int main(int argc, char **argv)
{
    if ([EMAIL PROTECTED](b) descriptionForInstanceMethod: @selector(aMethod)] != NULL)
printf("Ok\n");
}

</SNIP>

Compiling with

gcc -lobjc

Running

a.out

-> Segmentation fault


The segfault occurs in the libobjc when the Protocol tries to check it's
parents. The 'protocols'-Array contains a pointer which does _not_ point to the
parent protocol! That's why the prog crashes.

When inserting the line

    if ([EMAIL PROTECTED](a) descriptionForInstanceMethod: @selector(aMethod)] != NULL)
printf("Ok\n");

as first line in the main-method all is good. The protocol 'a' (the parent) is
initialized and 'b' finds it's parent and the line that caused the crash before
is running without problems.

This is extremly critical to me and maybe a patch could be posted here so I can
patch my gcc?


P.S.: I set the component to 'libobjc' because I think that it's containing the
objc-runtime. Is this correct?

-- 
           Summary: Protocols are not initialized correctly
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: libobjc
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tilo at pruetz dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18255

Reply via email to