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-9011] Assertion failure: (Index < Length && "Invalid index!") inside swift::GenericSignatureBuilder::PotentialArchetype::getDependentType #51514

Closed
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

nathawes commented Oct 16, 2018

Previous ID SR-9011
Radar rdar://problem/45293178
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: 943627e5068bd6885d10d4dad5563db9

Issue Description:

To reproduce:

$ git clone https://github.com/ProcedureKit/ProcedureKit.git
$ cd ProcedureKit
$ git checkout -f d6389ea98ec2e0d17ab368f40045bfe48622ac67
$ open ProcedureKit.xcodeproj

Then in Xcode:

  1. Select the October 3 swift.org dev toolchain

  2. Select the "ProcedureKit > My Mac" scheme

  3. Navigate to Any.swift

  4. Replace its contents with the below:

    struct ValueBox<Value> {
    
    enum ProcedureOutputBoxCreator {
        static func outputBox<P: OutputProcedure>(for procedure: P) -> ValueBox<Pending<ProcedureResult<P.Output>>> {
            let getter = { return procedure.output
    
    enum ProcedureInputBoxCreator {
        static func inputBox<P: InputProcedure>(for procedure: P) -> ValueBox<Pending<P.Input>> {
            let
    
    public class AnyInputProcedure<Input>: GroupProcedure {
        public var input: Pending<Input> {
            get {
                return self.inputBox
  5. Then build to get the assertion below:

    Application Specific Information:  
    Stack dump:  
    0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-10-03-a.xctoolchain/usr/bin/swift -frontend -c ...  
    1. While walking into initializer for declaration 0x7fed75249888 at /Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/ProcedureKit/Sources/ProcedureKit/Any.swift:11:9  
    2. While evaluating request IsObjCRequest(ProcedureKit.(file).ValueBox.ProcedureOutputBoxCreator.outputBox(for🙂.explicit closure discriminator=0.ProcedureInputBoxCreator.inputBox(for🙂.AnyInputProcedure.\_@/Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/ProcedureKit/Sources/ProcedureKit/Any.swift:19:9)  
    3. While evaluating request IsObjCRequest(ProcedureKit.(file).ValueBox.ProcedureOutputBoxCreator.outputBox(for🙂.explicit closure discriminator=0.ProcedureInputBoxCreator.inputBox(for🙂.AnyInputProcedure.input@/Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/ProcedureKit/Sources/ProcedureKit/Any.swift:18:16)  
    4. While validating 'AnyInputProcedure' at /Users/nathanhawes/workspace/open-swift-source-compat-suite-master/project_cache/ProcedureKit/Sources/ProcedureKit/Any.swift:17:8
    
    Assertion failed: (Index \< Length && "Invalid index!"), function operator\[\], file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/llvm/include/llvm/ADT/ArrayRef.h, line 241.
    
    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread  
    0 libsystem_kernel.dylib 0x00007fff7443bb86 \_\_pthread_kill + 10  
    1 libsystem_pthread.dylib 0x00007fff744f1c50 pthread_kill + 285  
    2 libsystem_c.dylib 0x00007fff743a5268 \_\_abort + 144  
    3 libsystem_c.dylib 0x00007fff743a51d8 abort + 142  
    4 libsystem_c.dylib 0x00007fff7436d868 \_\_assert_rtn + 320  
    5 swift 0x000000010976360f swift::GenericSignatureBuilder::PotentialArchetype::getDependentType(swift::ArrayRefView\<swift::Type, swift::GenericTypeParamType\*, swift::GenericTypeParamType\* swift::staticCastHelper\<swift::GenericTypeParamType\>(swift::Type const&), true\>) const + 319  
    6 swift 0x0000000109760d33 swift::GenericSignatureBuilder::ResolvedType::getDependentType(swift::GenericSignatureBuilder&) const + 51  
    7 swift 0x000000010976dc7e swift::GenericSignatureBuilder::addConformanceRequirement(swift::GenericSignatureBuilder::ResolvedType, swift::ProtocolDecl\*, swift::GenericSignatureBuilder::FloatingRequirementSource) + 174  
    8 swift 0x000000010976f58d swift::GenericSignatureBuilder::addTypeRequirement(llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, swift::GenericSignatureBuilder::FloatingRequirementSource, swift::GenericSignatureBuilder::UnresolvedHandlingKind, swift::ModuleDecl\*) + 733  
    9 swift 0x000000010978a048 swift::GenericSignatureBuilder::ConstraintResult llvm::function_ref\<swift::GenericSignatureBuilder::ConstraintResult (swift::Type, swift::TypeRepr const\*)\>::callback_fn\<swift::GenericSignatureBuilder::addInheritedRequirements(swift::TypeDecl\*, llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, swift::GenericSignatureBuilder::RequirementSource const\*, swift::ModuleDecl\*)::$\_34\>(long, swift::Type, swift::TypeRepr const\*) + 328  
    10 swift 0x0000000109781f0c std::\_*1::function::func\<visitInherited(llvm::PointerUnion\<swift::TypeDecl\*, swift::ExtensionDecl\*\>, llvm::function_ref\<swift::GenericSignatureBuilder::ConstraintResult (swift::Type, swift::TypeRepr const\*)\>)::$*70, std::*\_1::allocator\<visitInherited(llvm::PointerUnion\<swift::TypeDecl\*, swift::ExtensionDecl\*\>, llvm::function_ref\<swift::GenericSignatureBuilder::ConstraintResult (swift::Type, swift::TypeRepr const\*)\>)::$\_70\>, void (swift::Type, swift::TypeRepr const\*)\>::operator()(swift::Type&&, swift::TypeRepr const\*&&) + 268  
    11 swift 0x000000010976bc83 swift::GenericSignatureBuilder::addInheritedRequirements(swift::TypeDecl\*, llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, swift::GenericSignatureBuilder::RequirementSource const\*, swift::ModuleDecl\*) + 691  
    12 swift 0x000000010976c761 swift::GenericSignatureBuilder::expandConformanceRequirement(swift::GenericSignatureBuilder::ResolvedType, swift::ProtocolDecl\*, swift::GenericSignatureBuilder::RequirementSource const\*, bool) + 2609  
    13 swift 0x000000010976f58d swift::GenericSignatureBuilder::addTypeRequirement(llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, swift::GenericSignatureBuilder::FloatingRequirementSource, swift::GenericSignatureBuilder::UnresolvedHandlingKind, swift::ModuleDecl\*) + 733  
    14 swift 0x000000010978a048 swift::GenericSignatureBuilder::ConstraintResult llvm::function_ref\<swift::GenericSignatureBuilder::ConstraintResult (swift::Type, swift::TypeRepr const\*)\>::callback_fn\<swift::GenericSignatureBuilder::addInheritedRequirements(swift::TypeDecl\*, llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, swift::GenericSignatureBuilder::RequirementSource const\*, swift::ModuleDecl\*)::$\_34\>(long, swift::Type, swift::TypeRepr const\*) + 328  
    15 swift 0x0000000109781f0c std::1::function::*\_func\<visitInherited(llvm::PointerUnion\<swift::TypeDecl\*, swift::ExtensionDecl\*\>, llvm::function_ref\<swift::GenericSignatureBuilder::ConstraintResult (swift::Type, swift::TypeRepr const\*)\>)::$*70, std::*\_1::allocator\<visitInherited(llvm::PointerUnion\<swift::TypeDecl\*, swift::ExtensionDecl\*\>, llvm::function_ref\<swift::GenericSignatureBuilder::ConstraintResult (swift::Type, swift::TypeRepr const\*)\>)::$\_70\>, void (swift::Type, swift::TypeRepr const\*)\>::operator()(swift::Type&&, swift::TypeRepr const\*&&) + 268  
    16 swift 0x000000010976bc83 swift::GenericSignatureBuilder::addInheritedRequirements(swift::TypeDecl\*, llvm::PointerUnion\<swift::GenericSignatureBuilder::PotentialArchetype\*, swift::Type\>, swift::GenericSignatureBuilder::RequirementSource const\*, swift::ModuleDecl\*) + 691  
    17 swift 0x000000010976b950 swift::GenericSignatureBuilder::addGenericParameterRequirements(swift::GenericTypeParamDecl\*) + 96  
    18 swift 0x0000000109436ffb checkGenericParamList(swift::TypeChecker&, swift::GenericSignatureBuilder\*, swift::GenericParamList\*, swift::GenericSignature\*, swift::TypeResolution) + 203  
    19 swift 0x000000010943c7a0 void llvm::function_ref\<void (swift::GenericParamList\*)\>::callback_fn\<swift::TypeChecker::checkGenericEnvironment(swift::GenericParamList\*, swift::DeclContext\*, swift::GenericSignature\*, bool, swift::ExtensionDecl\*, llvm::function_ref\<void (swift::GenericSignatureBuilder&)\>, bool)::$\_5\>(long, swift::GenericParamList\*) + 96  
    20 swift 0x000000010943a8da visitOuterToInner(swift::GenericParamList\*, llvm::function_ref\<void (swift::GenericParamList\*)\>) + 42  
    21 swift 0x000000010943a31f swift::TypeChecker::checkGenericEnvironment(swift::GenericParamList\*, swift::DeclContext\*, swift::GenericSignature\*, bool, swift::ExtensionDecl\*, llvm::function_ref\<void (swift::GenericSignatureBuilder&)\>, bool) + 1119  
    22 swift 0x000000010943aa6e swift::TypeChecker::validateGenericTypeSignature(swift::GenericTypeDecl\*) + 382  
    23 swift 0x000000010940c048 swift::TypeChecker::validateDecl(swift::ValueDecl\*) + 648  
    24 swift 0x00000001094114e9 swift::TypeChecker::validateDeclForNameLookup(swift::ValueDecl\*) + 345  
    25 swift 0x000000010942232d swift::isRepresentableInObjC(swift::VarDecl const\*, swift::ObjCReason) + 109  
    26 swift 0x0000000109423ec7 swift::IsObjCRequest::evaluate(swift::Evaluator&, swift::ValueDecl\*) const + 1127  
    27 swift 0x000000010947dfe1 swift::SimpleRequest\<swift::IsObjCRequest, (swift::CacheKind)2, bool, swift::ValueDecl\*\>::evaluateRequest(swift::IsObjCRequest const&, swift::Evaluator&) + 17  
    28 swift 0x000000010972bf47 llvm::Expected\<swift::IsObjCRequest::OutputType\> swift::Evaluator::getResultUncached\<swift::IsObjCRequest\>(swift::IsObjCRequest const&) + 583  
    29 swift 0x000000010972bc18 llvm::Expected\<swift::IsObjCRequest::OutputType\> swift::Evaluator::getResultCached\<swift::IsObjCRequest, (void\*)0\>(swift::IsObjCRequest const&) + 56  
    30 swift 0x000000010972b5e0 llvm::Expected\<swift::IsObjCRequest::OutputType\> swift::Evaluator::operator()\<swift::IsObjCRequest\>(swift::IsObjCRequest const&) + 192  
    31 swift 0x00000001097150b2 swift::IsObjCRequest::OutputType swift::evaluateOrDefault\<swift::IsObjCRequest\>(swift::Evaluator&, swift::IsObjCRequest, swift::IsObjCRequest::OutputType) + 34  
    32 swift 0x00000001094231a3 shouldMarkAsObjC(swift::ValueDecl const\*, bool) + 467  
    33 swift 0x0000000109423b23 swift::IsObjCRequest::evaluate(swift::Evaluator&, swift::ValueDecl\*) const + 195  
    34 swift 0x000000010947dfe1 swift::SimpleRequest\<swift::IsObjCRequest, (swift::CacheKind)2, bool, swift::ValueDecl\*\>::evaluateRequest(swift::IsObjCRequest const&, swift::Evaluator&) + 17  
    35 swift 0x000000010972bf47 llvm::Expected\<swift::IsObjCRequest::OutputType\> swift::Evaluator::getResultUncached\<swift::IsObjCRequest\>(swift::IsObjCRequest const&) + 583  
    36 swift 0x000000010972bc18 llvm::Expected\<swift::IsObjCRequest::OutputType\> swift::Evaluator::getResultCached\<swift::IsObjCRequest, (void\*)0\>(swift::IsObjCRequest const&) + 56  
    37 swift 0x000000010972b5e0 llvm::Expected\<swift::IsObjCRequest::OutputType\> swift::Evaluator::operator()\<swift::IsObjCRequest\>(swift::IsObjCRequest const&) + 192  
    38 swift 0x00000001097150b2 swift::IsObjCRequest::OutputType swift::evaluateOrDefault\<swift::IsObjCRequest\>(swift::Evaluator&, swift::IsObjCRequest, swift::IsObjCRequest::OutputType) + 34  
    39 swift 0x00000001093ea6a5 (anonymous namespace)::FindCapturedVars::walkToExprPre(swift::Expr\*) + 69  
    40 swift 0x00000001096f1ab0 swift::ASTVisitor\<(anonymous namespace)::Traversal, swift::Expr\*, swift::Stmt\*, bool, swift::Pattern\*, bool, void\>::visit(swift::Stmt\*) + 1664  
    41 swift 0x00000001096f14f7 swift::ASTVisitor\<(anonymous namespace)::Traversal, swift::Expr\*, swift::Stmt\*, bool, swift::Pattern\*, bool, void\>::visit(swift::Stmt\*) + 199  
    42 swift 0x00000001096ee4b7 swift::Stmt::walk(swift::ASTWalker&) + 87  
    43 swift 0x00000001093e9326 swift::TypeChecker::computeCaptures(swift::AnyFunctionRef) + 438  
    44 swift 0x00000001093ebfd4 (anonymous namespace)::FindCapturedVars::propagateCaptures(swift::AnyFunctionRef, swift::SourceLoc) + 36  
    45 swift 0x00000001093eb85b (anonymous namespace)::FindCapturedVars::walkToDeclPre(swift::Decl\*) + 59  
    46 swift 0x00000001096ee9cb (anonymous namespace)::Traversal::doIt(swift::Decl\*) + 171  
    47 swift 0x00000001096f3d3b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl\*) + 459  
    48 swift 0x00000001096ee9f8 (anonymous namespace)::Traversal::doIt(swift::Decl\*) + 216  
    49 swift 0x00000001096f1608 swift::ASTVisitor\<(anonymous namespace)::Traversal, swift::Expr\*, swift::Stmt\*, bool, swift::Pattern\*, bool, void\>::visit(swift::Stmt\*) + 472  
    50 swift 0x00000001096ee4b7 swift::Stmt::walk(swift::ASTWalker&) + 87  
    51 swift 0x00000001093e9326 swift::TypeChecker::computeCaptures(swift::AnyFunctionRef) + 438  
    52 swift 0x00000001093ebfd4 (anonymous namespace)::FindCapturedVars::propagateCaptures(swift::AnyFunctionRef, swift::SourceLoc) + 36  
    53 swift 0x00000001093eb85b (anonymous namespace)::FindCapturedVars::walkToDeclPre(swift::Decl\*) + 59  
    54 swift 0x00000001096ee9cb (anonymous namespace)::Traversal::doIt(swift::Decl\*) + 171  
    55 swift 0x00000001096f3d3b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl\*) + 459  
    56 swift 0x00000001096ee9f8 (anonymous namespace)::Traversal::doIt(swift::Decl\*) + 216  
    57 swift 0x00000001096f1608 swift::ASTVisitor\<(anonymous namespace)::Traversal, swift::Expr\*, swift::Stmt\*, bool, swift::Pattern\*, bool, void\>::visit(swift::Stmt\*) + 472  
    58 swift 0x00000001096ee4b7 swift::Stmt::walk(swift::ASTWalker&) + 87  
    59 swift 0x00000001093e9326 swift::TypeChecker::computeCaptures(swift::AnyFunctionRef) + 438  
    60 swift 0x00000001093ebfd4 (anonymous namespace)::FindCapturedVars::propagateCaptures(swift::AnyFunctionRef, swift::SourceLoc) + 36  
    61 swift 0x00000001093ea903 (anonymous namespace)::FindCapturedVars::walkToExprPre(swift::Expr\*) + 675  
    62 swift 0x00000001096f345c swift::ASTVisitor\<(anonymous namespace)::Traversal, swift::Expr\*, swift::Stmt\*, bool, swift::Pattern\*, bool, void\>::visit(swift::Decl\*) + 652  
    63 swift 0x00000001096ee9f8 (anonymous namespace)::Traversal::doIt(swift::Decl\*) + 216  
    64 swift 0x00000001096f1608 swift::ASTVisitor\<(anonymous namespace)::Traversal, swift::Expr\*, swift::Stmt\*, bool, swift::Pattern\*, bool, void\>::visit(swift::Stmt\*) + 472  
    65 swift 0x00000001096ee4b7 swift::Stmt::walk(swift::ASTWalker&) + 87  
    66 swift 0x00000001093e9326 swift::TypeChecker::computeCaptures(swift::AnyFunctionRef) + 438  
    67 swift 0x00000001094a1943 typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 2403  
    68 swift 0x00000001094a228d swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet\<swift::TypeCheckingFlags, unsigned int\>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2061  
    69 swift 0x0000000109143a35 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 629  
    70 swift 0x0000000109143038 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616  
    71 swift 0x000000010847d067 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef\<char const\*\>, int&, swift::FrontendObserver\*, swift::UnifiedStatsReporter\*) + 1335  
    72 swift 0x000000010847ba9d swift::performFrontend(llvm::ArrayRef\<char const\*\>, char const\*, void\*, swift::FrontendObserver\*) + 3021  
    73 swift 0x000000010842df0e main + 686  
    74 libdyld.dylib 0x00007fff742fd085 start + 1
    
@nathawes
Copy link
Collaborator Author

@swift-ci create

@slavapestov
Copy link
Member

No longer crashing on master. I don’t know what fixed it but there were a number of changes in this area.

@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