Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10182] Segmentation Fault after updating to Xcode 10.2 #52584

Closed
swift-ci opened this issue Mar 26, 2019 · 3 comments
Closed

[SR-10182] Segmentation Fault after updating to Xcode 10.2 #52584

swift-ci opened this issue Mar 26, 2019 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 5.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10182
Radar rdar://problem/44736411
Original Reporter jon889 (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)

Target: x86_64-apple-darwin18.2.0

Xcode Version 10.2 (10E125)

macOS 10.14.3 (18D109)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, CompilerCrash
Assignee None
Priority Medium

md5: 655c9da91dc463b606d489113ce37451

duplicates:

  • SR-8814 GenericSignatureBuilder should re-introduce conformance requirements when adding a superclass requirement

relates to:

  • SR-10128 Compiler crashes when generic type constraint is the associated type of another protocol which the class also conforms to which and has a default implementation

Issue Description:

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
}

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
@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 2, 2019

Comment by Stuart Levine (JIRA)

jon889 (JIRA User) were you able to resolve this issue? I am having the same issue attempting to upgrade from Xcode 10.1 to Xcode 10.2 with Swift 5.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 2, 2019

Comment by Jonathan (JIRA)

No, we’ve delayed updated to swift 5. If this can break then it seems like it’s just not stable. If I remember correctly we can get around it though by removing fetchData declaration from the LoadingFetchedDataViewPresentable protocol and keeping it just in the extension.

@theblixguy
Copy link
Collaborator

I've seen similar crashes a few times now - it might be a bug in GSB and/or an optimisation pass before devirtualization. As a workaround, you can make your class final or use a struct instead.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 5.0
Projects
None yet
Development

No branches or pull requests

3 participants