Skip to content

[SR-10305] Type Checker SegFault #52705

@swift-ci

Description

@swift-ci
Previous ID SR-10305
Radar rdar://problem/49609518
Original Reporter calebkleveter (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug, 5.0Regression, CompilerCrash, TypeChecker
Assignee calebkleveter (JIRA)
Priority Medium

md5: e4a5f8345ebf8ab1fdd4181d3edcf4df

is duplicated by:

  • SR-10493 compiler crasher on [Substring].map(Int.init)
  • SR-10561 Compiler crash Type Checker
  • SR-10784 Compiler crash: Segmentation fault

Issue Description:

The Swift 5 type checker is crashing with a segfault when I try to convert an optional Substring to an Int:

public struct Version {
    public init?(_ string: String) {
        let components: [Substring] = string.split(separator: ".")
        guard let major: Int = components.first.flatMap(Int.init) else { return nil }
    }
}

The program compiles if I map over the Substring array and convert them so Strings.

Here is the gist with the compiler output: https://gist.github.com/calebkleveter/e6a7f3943b50e022ecd2beefbed44a6e

The crash occurs in both Xcode and the Terminal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareregressionswift 5.0type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions