Xcode 4.4.1 build crashing on Snow Leopard

2019-08-18 06:11发布

问题:

I have a project which I am compiling under OS X 10.7.4 using Xcode 4.4.1

I am using Base SDK SDKROOT macosx10.7 I have set Deployment Target MACOSX_DEPLOYMENT_TARGET 10.6

I tested a recent build on Snow Leopard and it crashed. Previous builds using Xcode 4.2 and 4.3 did work, and I can compile on Snow Leopard using Xcode version 3.2.6

Has anyone else had this experience, or better know what I can do to resolve it?

OS Version:      Mac OS X 10.6.8 (10K549)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000030
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
objc[274]: garbage collection is ON

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   com.apple.AppKit                 -[NSImage _allocAuxiliaryStorage] + 158
1   com.apple.AppKit                 -[NSImage copyWithZone:] + 66
2   libobjc.A.dylib                  objc_setProperty + 82
3            -[TreeViewController(Dirs) outlineView:willDisplayCell:forTableColumn:item:] + 207

PS Just restored Xcode 4.2.1 from TimeMachine backup and the build works on Snow Leopard

I "upgraded" to Mountain Lion - which would not allow Xcode 4.2.1 to run. (This also seemed to delete the OSX 10.8 and Xcode 4.4 SDK and the command line tools :-( ). This made it impossible to just use the precious compiler.

I tried to follow up where the crash was happening, which appeared to be in a call to setNodeIcon which was defined in one of my classes as

@property (copy) NSImage *nodeIcon;

I realise I will have to convert to ARC eventually, but was reluctant to embark on this yet. The conversion was far from straightforward and I am not sure I understand all the changes I was required to make (one file at a time) in particular the Toll-Free Bridging changes.

The resultant ARC code does seem to work on 10.6 - 10.8 but I need to do a lot of regression and leak testing to confirm.


Updated Comments 2012-09-18

The ARC code works but I found a couple of problems (which I have resolved) but need to do a lot more.

I went back to my GC code and changed copy to assign. This seemed to work.

@property (assign) NSImage *nodeIcon;

Just to confirm I made a standalone app (see below) which does nothing but copy an NSImage. This crashed in the same way, so it seems to be a bug in the compiler.

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate> {
    NSImage *nodeIcon;
}

@property (assign) IBOutlet NSWindow *window;
@property (copy) NSImage *nodeIcon;

@end

#import "AppDelegate.h"

@implementation AppDelegate
@synthesize nodeIcon;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    NSString *defaultDirectory = NSHomeDirectory();
    [self setNodeIcon:[[NSWorkspace sharedWorkspace] iconForFile:defaultDirectory]];
}

@end
标签: xcode4