bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Segfault when sending a message to a protocol


From: Nicola Pero
Subject: Re: Segfault when sending a message to a protocol
Date: Thu, 19 Sep 2002 11:11:17 +0100 (BST)

Hi Stefan,

this is a bug in the compiler ... all GCC ObjC compilers have it ...
except GCC 3.3 from CVS because I fixed it on GCC CVS one week ago :-)

The bug can be summarized shortly: objects created using @protocol() will
always crash when you send a message to them, unless a class implementing
that protocol is compiled in the same compilation unit.

So a workaround for older compilers is to add

@interface FakeClass <NSObject>
@end

@implementation FakeClass
@end

to your ObjC code.

GCC >= 3.3 does not have this problem.

> Hi,
> 
> I get segfault when sending a message to a protocol. 
> [snip]
> 
> Here is bactrace:
> 
> #0  0x4023ec6f in objc_msg_lookup () from /usr/local/lib/libobjc.so.1
> #1  0x080488ec in gnustep_base_user_main (argc=1, argv=0xbffff324) at 
> test.m:16
> #2  0x40148859 in main ()
>    from 
> /usr/GNUstep/System/Libraries/ix86/linux-gnu/gnu-gnu-gnu/libgnustep-base.so.1
> #3  0x4034714f in __libc_start_main () from /lib/libc.so.6
> 
> And here is an example that will crash:
> 
> ----
> 
> #import <Foundation/NSAutoreleasePool.h>
> #import <Foundation/NSObject.h>
> #import <Foundation/NSString.h>
> 
> int main(int argc, const char **argv)
> {     
>     NSAutoreleasePool *pool;
>     Protocol          *p;
> 
>     pool = [NSAutoreleasePool new];
> 
>     p = @protocol(NSObject);
>     NSLog(@"Protocol test %p",p);
>     /* Crash here ...*/
>     NSLog(@"Description   %p",[p 
> descriptionForInstanceMethod:@selector(class)]);
> 
>     RELEASE(pool);
> 
>     return 0;
> }
> 
> ----
> 
> Whan should be wrong?
> 
> Thank you,
> 
> Stefan
> 
> 
> 
> _______________________________________________
> Bug-gnustep mailing list
> Bug-gnustep@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-gnustep
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]