swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.28k stars 10.33k forks source link

[SR-13606] Swift Build fail with Error Segmentation fault: 11 #56041

Open swift-ci opened 3 years ago

swift-ci commented 3 years ago
Previous ID SR-13606
Radar rdar://problem/69549214
Original Reporter miku1958 (JIRA User)
Type Bug

Attachment: Download

Environment macOS 10.15.6 Xcode 12.2 beta
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | CodeCompletion, Compiler | |Labels | Bug | |Assignee | miku1958 (JIRA) | |Priority | Medium | md5: 96551868b73c577121953990fee850b6

Issue Description:

I removed the old description, and replaced the test project with a shortened version.

Xcode 12 builds with code like these will crash, including the 12.0 - 12.3 beta.

{code: swift}
@propertyWrapper
final class AlterKeys\<T> {

public var wrappedValue: T

public init(wrappedValue: @escaping @autoclosure () -> T, _ codingKeys: String...) {
self.wrappedValue = wrappedValue()
}
}
struct A {
// build fail in Xcode 12
@alterKeys("abc")
var key: Int = 0
}


But using the latest Swift snapshot from swift.org in Xcode will build successfully.

Then If I add another initialize function to the AlterKeys, It will build successfully too, like:
{code:swift}
@propertyWrapper
final class alterKeys<T> {

    public var wrappedValue: T

    public init(wrappedValue: @escaping @autoclosure () -> T, _ codingKeys: String...) {
        self.wrappedValue = wrappedValue()
    }
    public init(wrappedValue: @escaping @autoclosure () -> T) {
        self.wrappedValue = wrappedValue()
    }
}
struct A {
    // build success in Xcode 12
    @alterKeys("abc")
    var key: Int = 0
}
typesanitizer commented 3 years ago

@swift-ci create

jckarter commented 3 years ago

@eeckstein gave this a try in the main branch and it looks like it works now. You could try a main branch snapshot from swift.org to see if the problem is resolved for you in your actual project.

swift-ci commented 3 years ago

Comment by 庄黛淳华 (JIRA)

The building crash issue still not fix in Xcode 12.2 and 12.3 beta(Apple Swift version 5.3.2 (swiftlang-1200.0.44.1 clang-1200.0.32.28))