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-9009] Compiler crash in swift::GenericSignature::getASTContext() #51512

Closed
nathawes opened this issue Oct 16, 2018 · 2 comments
Closed

[SR-9009] Compiler crash in swift::GenericSignature::getASTContext() #51512

nathawes opened this issue Oct 16, 2018 · 2 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

@nathawes
Copy link
Collaborator

Previous ID SR-9009
Radar rdar://problem/45290211
Original Reporter @nathawes
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 5ce42fa811280e633b07c980a58bb1bd

Issue Description:

To reproduce:

$ git clone https://github.com/kickstarter/Kickstarter-Prelude
$ cd Kickstarter-Prelude
$ git checkout -f 9b2cc23ce8acf29b4b666a80a665c67cba800aac
$ open Prelude.xcodeproj

The in Xcode:

  1. Select the October 3 swift.org dev snapshot toolchain

  2. Select the "Prelude-iOS > Generic iOS Device" scheme

  3. Navigate to Array.swift

  4. Replace its contents with the below:

    public extension Array where Element: OptionalType {
      public func compact() -> [Element.Wrapped
    
    public extension Array where Element: Semigroup {
      public func sconcat(_ initial: Element) 
    
    public extension Array {
      public var randomElement: Element? {
        guard !self.isEmpty else 
    
    public extension Array where Element: Equatable {
      public func distincts() -> Array {
        return 
    
    extension Array: Semigroup {
      public func op(_ other: Array) -> Array {
    
    extension Array where Element: EitherType {
      func lefts() -> [Element.A] 
  5. Build to get the crash below:

    Application Specific Information:
    Stack dump:
    0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-10-03-a.xctoolchain/usr/bin/swift -frontend -typecheck -primary-file ...
    1.  While type-checking 'op(_:)' at /Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/Kickstarter-Prelude/Prelude/Array.swift:38:22
    2.  While type-checking statement at [/Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/Kickstarter-Prelude/Prelude/Array.swift:38:55 - line:47:45] RangeText="{
     
                    extension Array where Element: EitherType {
     
                      /**
                       Extracts the left values from the array.
     
                       - returns: A new array of left values.
                       */
                      func lefts() -> [Element.A"
    3.  While type-checking extension of <<error type>> at /Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/Kickstarter-Prelude/Prelude/Array.swift:40:17
    4.  While type-checking 'lefts()' at /Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/Kickstarter-Prelude/Prelude/Array.swift:47:19
    5.  While validating 'lefts()' at /Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/Kickstarter-Prelude/Prelude/Array.swift:47:19
    6.  While resolving type [Element.A] at [/Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/Kickstarter-Prelude/Prelude/Array.swift:47:35 - line:47:45] RangeText="[Element.A"
     
    
    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   swift                           0x00000001053f2104 swift::GenericSignature::getASTContext() const + 4
    1   swift                           0x000000010512e9a8 swift::TypeResolution::resolveDependentMemberType(swift::Type, swift::DeclContext*, swift::SourceRange, swift::ComponentIdentTypeRepr*) const + 136
    2   swift                           0x0000000105132735 resolveIdentTypeComponent(swift::TypeResolution, llvm::ArrayRef<swift::ComponentIdentTypeRepr*>, swift::TypeResolutionOptions) + 1269
    3   swift                           0x0000000105131e4b swift::TypeChecker::resolveIdentifierType(swift::TypeResolution, swift::IdentTypeRepr*, swift::TypeResolutionOptions) + 155
    4   swift                           0x000000010513325a (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::TypeResolutionOptions) + 282
    5   swift                           0x0000000105133a64 (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::TypeResolutionOptions) + 2340
    6   swift                           0x00000001051314a1 swift::TypeResolution::resolveType(swift::TypeRepr*, swift::TypeResolutionOptions) + 225
    7   swift                           0x00000001051330b2 swift::TypeChecker::validateType(swift::TypeLoc&, swift::TypeResolution, swift::TypeResolutionOptions) + 98
    8   swift                           0x00000001050d5565 checkGenericFuncSignature(swift::TypeChecker&, swift::GenericSignatureBuilder*, swift::AbstractFunctionDecl*, swift::TypeResolution) + 325
    9   swift                           0x00000001050d5349 swift::TypeChecker::validateGenericFuncSignature(swift::AbstractFunctionDecl*) + 1545
    10  swift                           0x00000001050a94e3 swift::TypeChecker::validateDecl(swift::ValueDecl*) + 5923
    11  swift                           0x00000001050b2f70 (anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) + 48
    12  swift                           0x00000001050a4a18 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 184
    13  swift                           0x00000001050b32bb (anonymous namespace)::DeclChecker::visitExtensionDecl(swift::ExtensionDecl*) + 443
    14  swift                           0x00000001050a4a44 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 228
    15  swift                           0x00000001050a4956 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
    16  swift                           0x000000010511e243 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 451
    17  swift                           0x000000010511d578 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 136
    18  swift                           0x000000010511c114 swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 260
    19  swift                           0x000000010511cc4f swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 271
    20  swift                           0x000000010513d116 typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 310
    21  swift                           0x000000010513e28d swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2061
    22  swift                           0x0000000104ddfa35 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 629
    23  swift                           0x0000000104ddf038 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
    24  swift                           0x0000000104119067 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1335
    25  swift                           0x0000000104117a9d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
    26  swift                           0x00000001040c9f0e main + 686
    27  libdyld.dylib                   0x00007fff742fd085 start + 1
@nathawes
Copy link
Collaborator Author

@swift-ci create

@slavapestov
Copy link
Member

#20119

@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