Search code examples
iosswiftxcode10swift4.2

Segmentation fault 11 when migrating existing project to Xcode 10 GM seed


New Xcode GM seed (and also previous beta 6) fails to build with multiple Segmentation faults 11 errors (using swift 4.2). The error does not disappear even if I remove, rename or comment out the class(es) in question.

The project builds without problems on Swift 4.1 with Xcode 9.

Example class where the error appears:

import Foundation

/// Possible sides for a corner.
public enum CornerSide {
    /// Corner on the left side.
    case left,
    /// Corner on the right side.
    right
}

or

import Foundation

extension Int {
    var toString: String { return "\(self)" }
}

or

import Foundation

public class DemoStatistics: Statistics { }

Statistics class is a normal class with functions and extensions (nothing special).

Stack trace:

0  swift                    0x000000011199264a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x0000000111991dfe SignalHandler(int) + 302
2  libsystem_platform.dylib 0x00007fff7e337f5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fd691b0bcd8 _sigtramp + 326974872
4  swift                    0x000000010f17e126 swift::ProtocolConformanceRef::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 550
5  swift                    0x000000010f18a7f9 swift::SubstitutionMap::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 761
6  swift                    0x000000010f17e4fd swift::ProtocolConformance::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 749
7  swift                    0x000000010f17e7bb swift::ProtocolConformance::subst(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>) const + 1451
8  swift                    0x000000010eda6e59 swift::ConformanceChecker::ensureRequirementsAreSatisfied(bool)::GatherConformancesListener::satisfiedConformance(swift::Type, swift::Type, swift::ProtocolConformanceRef) + 201
9  swift                    0x000000010ed7cc2f swift::TypeChecker::checkGenericArguments(swift::DeclContext*, swift::SourceLoc, swift::SourceLoc, swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>, llvm::ArrayRef<swift::Requirement>, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, llvm::function_ref<bool (swift::TypeCheckRequest)>*, swift::OptionSet<swift::ConformanceCheckFlags, unsigned int>, swift::GenericRequirementsCheckListener*, swift::SubstOptions) + 1103
10 swift                    0x000000010eda6bcd swift::ConformanceChecker::ensureRequirementsAreSatisfied(bool) + 1325
11 swift                    0x000000010edc24ba swift::ConformanceChecker::resolveTypeWitnesses() + 378
12 swift                    0x000000010ed92973 swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 11347
13 swift                    0x000000010ed8f8c2 swift::MultiConformanceChecker::checkAllConformances() + 162
14 swift                    0x000000010eda8ac7 swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 4279
15 swift                    0x000000010edf2f94 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2388
16 swift                    0x000000010ea2d865 swift::CompilerInstance::performSema() + 4949
17 swift                    0x000000010dc1a59b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 731
18 swift                    0x000000010dc16dc5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
19 swift                    0x000000010dbbca35 main + 1349
20 libdyld.dylib            0x00007fff7e029015 start + 1
21 libdyld.dylib            0x00000000000000ac start + 2180870296

All classes where the error appears are in a framework that I am building and using in sample iOS app. Any help would be appreciated.


Solution

  • Managed to solve this one myself. The problem was with single generic class which inherited from the same protocol twice (once directly and once via another protocol).

    Strangely, swift 4.1 and Xcode 9 was Ok with that, and Segmentation fault 11 locations had nothing to do with where the actual error was.