Open groue opened 8 years ago
The compiler crashes when:
a protocol declares a rethrowing function
a public object (class or struct) has a property which adopts the protocol
the rethrowing function is called on the property
the code is compiled in the Release configuration
Here is a minimal sample code which reproduces the issue (I could make it crash in an Xcode project):
protocol P {
func f(closure: () throws -> Void) rethrows
}
// Segmentation fault: 11
// While running pass #​271294 SILFunctionTransform "Simplify CFG" on SILFunction "@_TFC4GRDB11PublicClass1ffT_T_"
public class PublicClass {
let p: P
init(p: P) {
self.p = p
}
public func f() {
p.f { _ in }
}
}
// No error
class InternalClass {
let p: P
init(p: P) {
self.p = p
}
public func f() {
p.f { _ in }
}
}
// Segmentation fault: 11
// While running pass #​271367 SILFunctionTransform "Simplify CFG" on SILFunction "@_TFV4GRDB12PublicStruct1ffT_T_".
public struct PublicStruct {
let p: P
init(p: P) {
self.p = p
}
public func f() {
p.f { _ in }
}
}
// No error
struct InternalStruct {
let p: P
init(p: P) {
self.p = p
}
public func f() {
p.f { _ in }
}
}
Looks like we've fixed this in master. @eeckstein, do you know what would have fixed this?
No. There were no changes in SimplifyCFG which could have fixed this. I'm still investigating...
Found it. It was fixed by 226e4a725d0f053b93bd0e429d6bd18af318a955 "Fix a bug related to the opened archetypes tracking"
Assigning to Roman as he has fixed it.
Comment by Dan Thorpe (JIRA)
Can be re-produced when an internal type has property which adopts the protocol. Not just public.
danthorpe (JIRA User), can you attach your project, so we can try it against master?
Comment by Dan Thorpe (JIRA)
@belkadan sure, sorry for the delay...
Checkout this commit/project: https://github.com/ProcedureKit/ProcedureKit/commit/bf77b7b6e8f46cde00bb1d3bd8a923266f2c37d4 and then compile the ProcedureKit target for Mac.
git clone https://github.com/ProcedureKit/ProcedureKit.git
git fetch origin
git checkout bf77b7b6e8f46cde00bb1d3bd8a923266f2c37d4
Compiling in Release configuration gives:
The type in question is a generic abstraction to provide many-reads/single-write thread safety, see Protector in Sources/Support.swift
Also, this changeset was necessary to get round a Swift 3.0 (Xcode 8.0) release configuration compilation error (doesn't happen in debug configuration) - separate issue which you might be interested in too.
Comment by Dan Thorpe (JIRA)
@belkadan the crash is "fixed" with these changes: https://github.com/ProcedureKit/ProcedureKit/commit/a31ebc3a2ef3b1ba237c9d43b464527d020bf41b
Thanks, Dan. Reopening for now. @swiftix?
I'm looking into it. When I tried to reproduce with the ToT compiler, I'm running into a different issue. The compiler crashes in the devirtualizer. Seems like this new bug was introduced very recently.
Environment
Xcode 8 GM Version 8.0 (8A218a), SWIFT_VERSION=3.0Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, OptimizedOnly | |Assignee | @swiftix | |Priority | Medium | md5: 44aba97a60df66fb84678b64067ecd23Issue Description:
Hello,
The Swift 3 compiler embedded in Xcode 8 GM Version 8.0 (8A218a) crashes when building the GRDBOSX scheme in Release configuration of https://github.com/groue/GRDB.swift/tree/a8906da890820a0c9090821569c33d411efc9d8f
Steps to reproduce:
1. download the project at https://github.com/groue/GRDB.swift/tree/a8906da890820a0c9090821569c33d411efc9d8f
Compiler crashes with Segmentation fault 11 "While running pass #410260 SILFunctionTransform "Simplify CFG" on SILFunction "@TFC4GRDB24FetchedRecordsController12performFetchfT_T"."
I could not build a smaller sample code which exhibits the issue, unfortunately. It looks like the trouble lies in the DatabaseWriter protocol, which crashes the compiler when it is used.