Question

Why does this code crash in 64 bit? - It works fine 32 bit.

It's loading a nib for a UIView

- (id) awakeAfterUsingCoder:(NSCoder*)aDecoder {

    BOOL theThingThatGotLoadedWasJustAPlaceholder = ([[self subviews] count] == 0);

    if (theThingThatGotLoadedWasJustAPlaceholder) {

        ALTimelineView* theRealThing = [[self class] loadFromNib];

        // pass properties through
        theRealThing.frame = self.frame;
        theRealThing.autoresizingMask = self.autoresizingMask;
        theRealThing.alpha = self.alpha;
        theRealThing.hidden = self.hidden;

        [theRealThing internalInit];

        // convince ARC that we're legit
        CFRelease((__bridge const void*)self);
        CFRetain((__bridge const void*)theRealThing);

        return theRealThing;
    }
    return self;
}

loadFromNib

+ (id) loadFromNib {

    NSString* nibName = NSStringFromClass([self class]);
    NSArray* elements = [[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil];

    for (NSObject* anObject in elements) {
        if ([anObject isKindOfClass:[self class]]) {
            return anObject;
        }
    }
    return nil;
}

The error I'm getting is EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

Was it helpful?

Solution

EXC_I386_GPFLT is surely referring to "General Protection fault", which is the x86's way to tell you that "you did something that you are not allowed to do". It typically DOESN'T mean that you access out of memory bounds, but it could be that your code is going out of bounds and causing bad code/data to be used in a way that makes for an protection violation of some sort.

check this Reference Link for good explanation of EXC_I386_GPFLT

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top