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-8493] Swift 4.2 compiler crash with generics and protocols #51014

Closed
keith opened this issue Aug 8, 2018 · 3 comments
Closed

[SR-8493] Swift 4.2 compiler crash with generics and protocols #51014

keith opened this issue Aug 8, 2018 · 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

Comments

@keith
Copy link
Collaborator

keith commented Aug 8, 2018

Previous ID SR-8493
Radar None
Original Reporter @keith
Type Bug
Status Resolved
Resolution Done
Environment

Swift 4.2
Xcode 10 beta 5

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

md5: 49192be13e2c044a0801f3a9f254d123

Issue Description:

With this code in 2 separate files:

main.swift:

StateAnimatorGroup<String>().set("")

second.swift:

class StateAnimatorGroup<State> {
    func add<T: StateAnimator>(_ animator: T) where T.State == State {}
    func set(_ state: State) {}
}

extension StateAnimatorGroup: StateAnimator where State == String {}

protocol StateAnimator {
    associatedtype State

    func set(_ state: State)
}

If you compiling them using Swift 4.2 (from Xcode 10 beta 5) with this command:

swiftc -swift-version 4.2 main.swift second.swift

You get this compiler crash:

0  swift                    0x000000010f03cc5a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010f03c3fe SignalHandler(int) + 302
2  libsystem_platform.dylib 0x00007fff50e5ef5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007ffee4989af8 _sigtramp + 2477960120
4  swift                    0x000000010c852383 llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions)::$_19>(long, swift::TypeBase*) + 819
5  swift                    0x000000010c84df28 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 56
6  swift                    0x000000010c851525 substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions) + 261
7  swift                    0x000000010be700b3 llvm::Optional<swift::Requirement> swift::Requirement::subst<swift::SubstitutionMap&>(swift::SubstitutionMap&&&) const + 115
8  swift                    0x000000010c7c8ebe swift::GenericSignatureBuilder::InferRequirementsWalker::walkToTypePost(swift::Type) + 350
9  swift                    0x000000010c7c75c8 swift::GenericSignatureBuilder::addRequirement(swift::RequirementRepr const*, swift::GenericSignatureBuilder::FloatingRequirementSource, swift::SubstitutionMap const*, swift::ModuleDecl*) + 2840
10 swift                    0x000000010c435b96 swift::TypeChecker::checkGenericParamList(swift::GenericSignatureBuilder*, swift::GenericParamList*, swift::GenericSignature*, swift::GenericTypeResolver*) + 646
11 swift                    0x000000010c437916 checkGenericFuncSignature(swift::TypeChecker&, swift::GenericSignatureBuilder*, swift::AbstractFunctionDecl*, swift::GenericTypeResolver&) + 166
12 swift                    0x000000010c436f17 swift::TypeChecker::validateGenericFuncSignature(swift::AbstractFunctionDecl*) + 487
13 swift                    0x000000010c404226 swift::TypeChecker::validateDecl(swift::ValueDecl*) + 20326
14 swift                    0x000000010c42b193 swift::TypeChecker::finalizeDecl(swift::ValueDecl*) + 259
15 swift                    0x000000010c4b3278 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2856
16 swift                    0x000000010c0edfbe swift::CompilerInstance::performSema() + 4238
17 swift                    0x000000010b2f3bfb performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 731
18 swift                    0x000000010b2f0425 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
19 swift                    0x000000010b296175 main + 1349
20 libdyld.dylib            0x00007fff50b50015 start + 1
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file main.swift second.swift -target x86_64-apple-darwin17.6.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -swift-version 4.2 -module-name main -o /var/folders/tm/5q4s5knd5jj3qgh4lq_37kd80000gp/T/main-8f8403.o 
1.  While validating 'add(_:)' at second.swift:2:5
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)

Notes:

  • If you move them to the same file this is solved

  • If you rename the generic on StateAnimatorGroup to something else, it's solved

@keith
Copy link
Collaborator Author

keith commented Aug 15, 2018

This seems to be fixed with Xcode 10 beta 6

@belkadan
Copy link
Contributor

Adding a regression test in #19068

@keith
Copy link
Collaborator Author

keith commented Aug 30, 2018

Thanks!

@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
Projects
None yet
Development

No branches or pull requests

3 participants