discuss-gnustep
[Top][All Lists]
Advanced

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

Re: ANN: GNUstep Objective-C Runtime 1.2


From: Thomas Davie
Subject: Re: ANN: GNUstep Objective-C Runtime 1.2
Date: Mon, 21 Feb 2011 22:49:54 +0000

On 21 Feb 2011, at 22:38, David Chisnall wrote:

> Nope, that's expected.  The configure test is checking GNU Vs NeXT there.  It 
> places the GCC and GNUstep runtimes in one category and the NeXT (Apple 
> Legacy) and Apple (Apple Modern) runtimes in the other category.  
> 
> This is because gcc and clang use -fgnu-runtime and -fnext-runtime to select 
> between the two ABIs, with -fobjc-nonfragile-abi to differentiate within the 
> group:
> 
> -fgnu-runtime:                                                GCC ABI 
> (supported by GCC and GNUstep runtimes)
> -fgnu-runtime -fobjc-nonfragile-abi:          GNUstep ABI (GNUstep runtime 
> only, maybe GCC 4.7 runtime?)
> -fnext-runtime:                                               Apple Legacy 
> runtime / NeXT runtime
> -fnext-runtime -fobjc-nonfragile-abi          Apple Modern runtime
> 
> On OS X, selecting -m32 or -m64 also slightly changes the ABI, but not much.
> 
> If you are using clang and the GNUstep runtime, I'd recommend that you also 
> tell make's configure script that you want to use the non-fragile ABI.  This 
> gives you a few extra things (non-fragile ivars, proper support for 
> -forwardingTargetForSelector:, safe automatic IMP caching).  

Thanks very much,

Given this, I believe I now have gnustep-base compiled with the new runtime, 
and am compiling a pair of test programs that seem to be exhibiting erroneous 
behaviour:

The first[Test1] attempts to put a block in an array and take it out again, and 
seg faults while doing so:
2011-02-21 22:43:23.246 Test[27776] Hello world
2011-02-21 22:43:23.251 Test[27776] Hello world
Segmentation fault

The second[Test2] attempts to use @synchronized for an atomic setter method, 
and similarly seg faults – the same happens when tried with @synthesized atomic 
properties:
2011-02-21 22:43:46.807 Test[27828] Attempting to set nonatomic property
2011-02-21 22:43:46.813 Test[27828] Set
2011-02-21 22:43:46.813 Test[27828] Attempting to set atomic property
Segmentation fault

Where is the correct place for me to put these?

Bob


[Test1]
#import <Foundation/Foundation.h>

int main (int argc, char **argv)
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    void (^hello)(void) = ^() { NSLog(@"Hello world"); };
    hello();
    void (^helloCopy)(void) = Block_copy(hello);
    helloCopy();
    NSArray *blockArr = [NSArray arrayWithObject:helloCopy];
    NSLog(@"Block went into array okay");
    void (^helloArr)(void) = [blockArr objectAtIndex:0];
    helloArr();
    Block_release(helloCopy);
    [pool drain];
    return 0;
}

[Test2]
#import <Foundation/Foundation.h>

@interface A : NSObject
{
@private
    NSObject *n;
    NSObject *a;
}

@property (nonatomic,readwrite,retain) NSObject *n;
@property (readwrite,retain) NSObject *a;

@end

@implementation A

- (NSObject *)n
{
    return [[n retain] autorelease];
}

- (void)setN:(NSObject *)newN
{
    if (n != newN)
    {
        [n release];
        n = [newN retain];
    }
}

- (NSObject *)a
{
    return [[a retain] autorelease];
}

- (void)setA:(NSObject *)newA
{
    @synchronized(self)
    {
        if (a != newA)
        {
            [a release];
            a = [newA retain];
        }
    }
}

@end

int main (int argc, char **argv)
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
    A *a = [[[A alloc] init] autorelease];
    NSObject *obj = [[[NSObject alloc] init] autorelease];
    NSLog(@"Attempting to set nonatomic property");
    a.n = obj;
    NSLog(@"Set");
    NSLog(@"Attempting to set atomic property");
    a.a = obj;
    NSLog(@"Set");

    [pool drain];
    return 0;
}




reply via email to

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