Segmentation Fault 11 after updating to Xcode 10.2

Not entirely sure where to post this.

Just updated to Xcode 10.2 and was trying to get the project to compile so that I could convert to Swift 5. So this is still using swift 4.2 mode.

I got a segmentation fault: 11 error. Here is some reduced code that provides the minimal code to replicate the issue:

public protocol ErrorViewModelType {}

public protocol LoadingFetchedDataViewPresentable {
    associatedtype ErrorViewModel: ErrorViewModelType //Must require a type
    func fetchData()
}

public extension LoadingFetchedDataViewPresentable {
    func fetchData() {} //This must be here to satisfy the requirement from FetchedDataViewPresentable
}

class Foo<T: ErrorViewModelType>: LoadingFetchedDataViewPresentable {

    //Renaming T to ErrorViewModel and removing the typealias does not fix crash
    typealias ErrorViewModel = T //Required to come from Generic parameter
}

I appreciate it's kind of complicated and it is code that we should refactor, however each protocol is used in other places in the real code base.

This code worked fine in Xcode 10.1, and doesn't look invalid to me.

This is the full error:

While emitting IR SIL function "@$s18SwiftCompilerCrash3FooCyqd__GAA33LoadingFetchedDataViewPresentableA2aEP05fetchG0yyFTW".
 for 'fetchData()' (at /Users/jonathan/Documents/SwiftCompilerCrash/SwiftCompilerCrash/ViewController.swift:19:5)
0  swift                    0x000000010734fee3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010734f6bc SignalHandler(int) + 348
2  libsystem_platform.dylib 0x00007fff7b2e9b3d _sigtramp + 29
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2228315360
4  swift                    0x00000001031fcdc1 swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&, llvm::SmallPtrSetImpl<swift::ProtocolDecl*>*) + 65
5  swift                    0x00000001031fcd32 swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 450
6  swift                    0x00000001031fcb38 void llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>::callback_fn<swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&)::$_1>(long, unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>) + 1656
7  swift                    0x000000010334d53f swift::irgen::GenericTypeRequirements::enumerateFulfillments(swift::irgen::IRGenModule&, swift::SubstitutionMap, llvm::function_ref<void (unsigned int, swift::CanType, llvm::Optional<swift::ProtocolConformanceRef>)>) + 335
8  swift                    0x00000001031fbcea swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 490
9  swift                    0x00000001031fbac8 swift::irgen::FulfillmentMap::searchTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::irgen::IsExact_t, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 952
10 swift                    0x00000001033fa15a swift::irgen::IRGenFunction::bindLocalTypeDataFromTypeMetadata(swift::CanType, swift::irgen::IsExact_t, llvm::Value*, swift::MetadataState) + 314
11 swift                    0x000000010334aed4 swift::irgen::emitPolymorphicParameters(swift::irgen::IRGenFunction&, swift::SILFunction&, swift::irgen::Explosion&, swift::irgen::WitnessMetadata*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 580
12 swift                    0x00000001033b1f71 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8049
13 swift                    0x0000000103271259 swift::irgen::IRGenerator::emitLazyDefinitions() + 1353
14 swift                    0x0000000103392250 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1232
15 swift                    0x00000001031b40b9 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 49417
16 swift                    0x00000001031a46de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
17 swift                    0x00000001031427be main + 1246
18 libdyld.dylib            0x00007fff7b0feed9 start + 1
19 libdyld.dylib            0x000000000000004d start + 2230325621
error: Segmentation fault: 11

Any compiler crash is a bug, even if the code is invalid, so please file at https://bugs.swift.org!

That said, the code you have isn't crashing for me when I try to build it on its own from the command line, so maybe I'm missing something.

1 Like

Ah sorry, I've updated the code so now it crashes and is a bit more minimal.

Great, it reproduces for me now. Please file!

I filed it here: [SR-10182] Segmentation Fault after updating to Xcode 10.2 · Issue #52584 · apple/swift · GitHub

Hope that's correct!

1 Like