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-13248] Compiler crash (5.1.3) "while type-checking statement" #55688

Closed
swift-ci opened this issue Jul 18, 2020 · 5 comments
Closed

[SR-13248] Compiler crash (5.1.3) "while type-checking statement" #55688

swift-ci opened this issue Jul 18, 2020 · 5 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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13248
Radar None
Original Reporter ken (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Xcode: Version 11.3.1 (11C505)
macOS: 10.14.6 (18G5033)
Swift: Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15).

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

md5: b24279421f8f1c565dd703079d4b5041

Issue Description:

I wanted a string with all the ASCII digits, without typing them out by hand (too easy to miss one!), so I had no idea if the obvious approach would work but I thought it was worth a try:

let digits = ("0"..."9").joined()

Surprisingly, this crashed the compiler. The stack trace looks like this:

1.  While type-checking statement at [/tmp/Range Test/Range Test/main.swift:1:1 - line:1:33] RangeText="let digits = ("0"..."9").joined("
2.  While type-checking declaration 0x7f996b0decf0 (at /tmp/Range Test/Range Test/main.swift:1:1)
3.  While type-checking expression at [/tmp/Range Test/Range Test/main.swift:1:14 - line:1:33] RangeText="("0"..."9").joined("
0  swift                    0x000000010f754a63 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010f754236 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff69a75b5d _sigtramp + 29
3  libsystem_platform.dylib 0x00007ffee48f9d78 _sigtramp + 2062041656
4  swift                    0x000000010bdf940c swift::constraints::MissingConformanceFailure::diagnoseAsError() + 588
5  swift                    0x000000010bdf15c6 swift::constraints::MissingConformance::diagnose(swift::Expr*, bool) const + 406
6  swift                    0x000000010bd29064 swift::constraints::ConstraintSystem::applySolutionFixes(swift::Expr*, swift::constraints::Solution const&)::DiagnosticWalker::diagnose(swift::Expr*) + 260
7  swift                    0x000000010bd28dec swift::constraints::ConstraintSystem::applySolutionFixes(swift::Expr*, swift::constraints::Solution const&)::DiagnosticWalker::walkToExprPre(swift::Expr*) + 316
8  swift                    0x000000010c25eff4 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 36
9  swift                    0x000000010bd2959b swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool) + 1291
10 swift                    0x000000010bee1479 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 1161
11 swift                    0x000000010bee3602 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 898
12 swift                    0x000000010bee4381 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 225
13 swift                    0x000000010befb88c validatePatternBindingEntries(swift::TypeChecker&, swift::PatternBindingDecl*) + 572
14 swift                    0x000000010bef0351 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 3665
15 swift                    0x000000010bf9147e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 23854
16 swift                    0x000000010bf8b6f1 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 129
17 swift                    0x000000010bf94477 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 263
18 swift                    0x000000010bfafb98 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1656
19 swift                    0x000000010b6a2117 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 4679
20 swift                    0x000000010b395d66 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 806
21 swift                    0x000000010b392234 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
22 swift                    0x000000010b31f733 main + 1219
23 libdyld.dylib            0x00007fff6988a3d5 start + 1
error: Segmentation fault: 11 (in target 'Range Test' from project 'Range Test')

I tried looking for a duplicate, and there's many crashes "while type-checking statement", but I didn't see one that looked quite like this one.

@theblixguy
Copy link
Collaborator

Looks like this is fixed in Xcode 12 beta:

Referencing instance method 'joined(separator:)' on 'ClosedRange' requires that 'String' conform to 'Strideable'

@theblixguy
Copy link
Collaborator

By the way, you can do (0...9).map(String.init).joined() to get the string "0123456789".

@swift-ci
Copy link
Collaborator Author

Comment by Ken Harris (JIRA)

Great, thanks!

@theblixguy
Copy link
Collaborator

No worries![]( Please don't forget to mark the ticket as "Closed" once you've verified with Xcode 12 beta or development snapshot from swift.org) 🙂

@swift-ci
Copy link
Collaborator Author

Comment by Ken Harris (JIRA)

I don't have a macOS that can run Xcode > 11.3.1 (minimum OS requirements for Xcode go up really fast), but I downloaded "swift-DEVELOPMENT-SNAPSHOT-2020-07-17-a-ubuntu16.04" in a Linux VM and I can confirm this line of code does not segfault there.

Aside: I also need to generate "a"..."z", and generating that string in Swift is a bit more involved.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants