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-9042] Assertion `Index < Length && "Invalid index!"' failed #51545

Closed
tayloraswift opened this issue Oct 19, 2018 · 4 comments
Closed

[SR-9042] Assertion `Index < Length && "Invalid index!"' failed #51545

tayloraswift opened this issue Oct 19, 2018 · 4 comments
Assignees
Labels
compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software improvement

Comments

@tayloraswift
Copy link
Contributor

Previous ID SR-9042
Radar rdar://problem/45692538
Original Reporter @Kelvin13
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, CompilerCrash
Assignee @Kelvin13
Priority Medium

md5: b68d80c76870d18722d875dac549a132

Issue Description:

compiling the following makes the compiler crash

let u:() -> UInt8 = { .init("a" as Unicode.Scalar) }
swift: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/llvm/include/llvm/ADT/ArrayRef.h:241: const T &llvm::ArrayRef<swift::Requirement>::operator[](size_t) const [T = swift::Requirement]: Assertion `Index < Length && "Invalid index!"' failed.
Stack dump:
0. Program arguments: /home/klossy/tools/swift/usr/bin/swift -frontend -c -primary-file literal.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name literal -o /tmp/literal-1b74d5.o 
1. While type-checking statement at [literal.swift:29:1 - line:29:52] RangeText="let u:() -> UInt8 = { .init("a" as Unicode.Scalar) "
2. While type-checking declaration 0x7e0b560 at literal.swift:29:1
3. While type-checking expression at [literal.swift:29:21 - line:29:52] RangeText="{ .init("a" as Unicode.Scalar) "
/home/klossy/tools/swift/usr/bin/swift[0x41b04d4]
/home/klossy/tools/swift/usr/bin/swift[0x41ae25e]
/home/klossy/tools/swift/usr/bin/swift[0x41b0692]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7fe8eef69890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fe8ed3cce97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7fe8ed3ce801]
/lib/x86_64-linux-gnu/libc.so.6(+0x3039a)[0x7fe8ed3be39a]
/lib/x86_64-linux-gnu/libc.so.6(+0x30412)[0x7fe8ed3be412]
/home/klossy/tools/swift/usr/bin/swift[0x13777c8]
/home/klossy/tools/swift/usr/bin/swift[0x1377a4d]
/home/klossy/tools/swift/usr/bin/swift[0x1377b38]
/home/klossy/tools/swift/usr/bin/swift[0x1376d31]
/home/klossy/tools/swift/usr/bin/swift[0x14b6724]
/home/klossy/tools/swift/usr/bin/swift[0x17b87bb]
/home/klossy/tools/swift/usr/bin/swift[0x1768cf5]
/home/klossy/tools/swift/usr/bin/swift[0x1766ebb]
/home/klossy/tools/swift/usr/bin/swift[0x17ae062]
/home/klossy/tools/swift/usr/bin/swift[0x14942a6]
/home/klossy/tools/swift/usr/bin/swift[0x149450b]
/home/klossy/tools/swift/usr/bin/swift[0x13dffb5]
/home/klossy/tools/swift/usr/bin/swift[0x13e7256]
/home/klossy/tools/swift/usr/bin/swift[0x13e7569]
/home/klossy/tools/swift/usr/bin/swift[0x13f54e3]
/home/klossy/tools/swift/usr/bin/swift[0x13f4b2e]
/home/klossy/tools/swift/usr/bin/swift[0x147132c]
/home/klossy/tools/swift/usr/bin/swift[0x1470617]
/home/klossy/tools/swift/usr/bin/swift[0x1470542]
/home/klossy/tools/swift/usr/bin/swift[0x148f326]
/home/klossy/tools/swift/usr/bin/swift[0x11a32cb]
/home/klossy/tools/swift/usr/bin/swift[0x11a2260]
/home/klossy/tools/swift/usr/bin/swift[0x11a1828]
/home/klossy/tools/swift/usr/bin/swift[0x4bde26]
/home/klossy/tools/swift/usr/bin/swift[0x4bcae9]
/home/klossy/tools/swift/usr/bin/swift[0x46dfe0]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fe8ed3afb97]
/home/klossy/tools/swift/usr/bin/swift[0x46c3fa]
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

swift version is

swift --version
Swift version 4.2-dev (LLVM aeaaca98ed, Clang 1ddef2249a, Swift 20bb815b62)
Target: x86_64-unknown-linux-gnu

this crash does not seem to occur with the 4.2 toolchain

@belkadan
Copy link
Contributor

On a Mac build, with symbols:

7  swift                    0x000000010e270271 swift::constraints::RequirementFailure::getRequirement() const + 129
8  swift                    0x000000010e2705e2 swift::constraints::RequirementFailure::getRequirementDC() const + 18
9  swift                    0x000000010e27070b swift::constraints::RequirementFailure::diagnoseAsError() + 75
10 swift                    0x000000010e26f6b3 swift::constraints::MissingConformance::diagnose(swift::Expr*, bool) const + 195
11 swift                    0x000000010e200893 swift::Expr* llvm::function_ref<swift::Expr* (swift::Expr*)>::callback_fn<swift::constraints::ConstraintSystem::applySolutionFixes(swift::Expr*, swift::constraints::Solution const&)::$_11>(long, swift::Expr*) + 227
12 swift                    0x000000010e65bbae swift::Expr::forEachChildExpr(llvm::function_ref<swift::Expr* (swift::Expr*)>)::ChildWalker::walkToExprPre(swift::Expr*) + 14
13 swift                    0x000000010e5f91d2 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 6930
14 swift                    0x000000010e5f7074 swift::Expr::walk(swift::ASTWalker&) + 84
15 swift                    0x000000010e64e503 swift::Expr::forEachChildExpr(llvm::function_ref<swift::Expr* (swift::Expr*)>) + 51
16 swift                    0x000000010e1e0568 swift::constraints::ConstraintSystem::applySolutionFixes(swift::Expr*, swift::constraints::Solution const&) + 536
17 swift                    0x000000010e1e07ac swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool) + 60
18 swift                    0x000000010e2fe010 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1088
19 swift                    0x000000010e3031a5 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, bool) + 357
20 swift                    0x000000010e303481 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 273
21 swift                    0x000000010e312512 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 2610
22 swift                    0x000000010e311ad6 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
23 swift                    0x000000010e38b3b3 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 451
24 swift                    0x000000010e38a6ec bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 140
25 swift                    0x000000010e38a61e swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 174
26 swift                    0x000000010e3ab745 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2005
27 swift                    0x000000010e04be58 swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t, swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 472
28 swift                    0x000000010e04aa97 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 439
29 swift                    0x000000010e04a163 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 627
30 swift                    0x000000010d39ed86 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1334
31 swift                    0x000000010d39d7f1 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3009

@xedin, does this look familiar?

@xedin
Copy link
Member

xedin commented Oct 31, 2018

@swift-ci create

@xedin
Copy link
Member

xedin commented Oct 31, 2018

Fixed by #20176 I've also added your test-case to the suite, thank you!

Please verify using tomorrow's snapshot of master.

@tayloraswift
Copy link
Contributor Author

can confirm this no longer crashes. 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
compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software improvement
Projects
None yet
Development

No branches or pull requests

4 participants