Archive build results in Command failed due to signal: Segmentation fault: 11

Originator:crspybits
Number:rdar://23257608 Date Originated:10/26/15
Status:Open Resolved:10/26/15
Product:Xcode Product Version:7.01 or 7.1
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Description:
I have a project that builds normally in a debug build. When I attempt to build the project for release (Product -> Archive), the build fails with a segmentation fault (see output from compiler in attached .txt file).

Steps to reproduce:
Build the project for release (Product -> Archive)

Expected results:
The build should succeed and allow me to upload the .ipa

Actual results:
Seg fault.

Configuration:
Building with Xcode for "iOS Device"

Xcode Version/Build & OS X Version/Build
I've tried this both with Xcode 7.0.1 and 7.1 (production releases) and get the same result.

Additional Notes
The specific method where the compiler is failing is:

    public func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return self.sectionContents.count
    }

And the definition of sectionContents is:

    private var sectionContents: [[SMIAPProduct]]? {
        return self.productsInfo!.sectionContents(forClass: SMIAPStore.self)
    }

Comments

Resolved

I figured this out. It appears to be due to the compiler not dealing correctly with having a different method signature for an override in terms of an optional result. I had the following base class method definition:

public func sectionContents(forClass forClass:AnyClass) -> [[SMIAPProduct]]? {
    Assert.badMojo(alwaysPrintThisString: "Implement this in your subclass!")
    return nil
}

with the following subclass definition:

override public func sectionContents(forClass sectionContentsForClass:AnyClass) -> [[SMIAPProduct]] {
    if SMIAPStore.self == sectionContentsForClass {
        return [_storeCharacters] + [_storeBackgrounds]
    } else {
        return [_settingsCharacters] + [_settingsBackgrounds]
    }
}

Note the lack of an optional in the returned value for the subclass definition.

When I change the subclass definition (and the usages of this subclass method to account for the now optional result), to:

override public func sectionContents(forClass sectionContentsForClass:AnyClass) -> [[SMIAPProduct]]? {
    if SMIAPStore.self == sectionContentsForClass {
        let storeSectionContents:[[SMIAPProduct]] = [_storeCharacters] + [_storeBackgrounds]
        return storeSectionContents
    } else {
        let settingsSectionContents:[[SMIAPProduct]] = [_settingsCharacters] + [_settingsBackgrounds]
        return settingsSectionContents
    }
}

I no longer have the crash.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!