-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Compiler crash with lifetime issue with latest January trunk snapshots #78444
Comments
Can you test this again at main? I wonder if the recent change for the dependency tracking had an impact here. |
Using latest
If it is more recent than 2025-01-05, I can test again once a new toolchain is posted and the corresponding Android SDK is built.
|
Try it again with the Jan. 10 trunk tag, which has the fix for the similar error in #78447. |
No, it still crashes for me with the same stack trace, even without specifying any custom SDK. For the record, it is also crashing with the earlier You can try for yourself by attempting to build https://github.com/marcprux/swift-property-crash.git (which is just a snapshot of https://github.com/tayloraswift/swift-jpeg.git from before I submitted the patch to work around the crash).
|
OK, I'm able to reproduce by simply compiling your repo for linux x86_64 with the latest Jan. 10 trunk snapshot tag, so this is clearly not specific to any platform, updating title and labels to show that. |
@gottesmm, please refer this to the right person. |
I have a reproducer for a similar, if not, the same issue. It does produce a stack trace containing I'm compiling the following in Release mode with 6.0.3 Release 2024-12-10a. The build fails there. import Foundation
public enum H: Hashable, RawRepresentable { // Has to be both Hashable, RawRepresentable for the build to fail
case cc(String) // Has to be present for the build to fail.
case bb // We have to use "bb" and not "cc" in line 12, or the build will succeed.
public init?(rawValue: String) {fatalError()} // Needed for conformance to RawRepresentable
public var rawValue: String {fatalError()} // Needed for conformance to RawRepresentable
public func hash(into hasher: inout Hasher) {fatalError()} // Needed for conformance to Hashable
}
public protocol G {}
public extension G { // Has to be public for the build to fail.
func j(of m: H, to d: Date) {
guard m != .bb else { return }; // Need this line and the line below for the build to fail.
self.l(of: m, to: d) // Need this line and the line above for the build to fail.
}
func l(of key: H, to date: Date) {
if let self = self as? E {self.j(of: key, to: date)}
else {print(key)} // Has to be present for the build to fail. Printing "date" also causes the build to fail.
}
}
protocol E {func j(of: H, to: Date)}
enum F {}
extension F {final class X: G {init() {fatalError()}}} //At least one of classes X or Y have to be "final" for the build to fail.
extension F.X: E {}
extension F {final class Y: G {init() {fatalError()}}}
extension F.Y: E {} // We need this plus the line above for the build to fail. Deleting both will make it succeed.
|
I tried to find when this assertion failure was introduced and I see it on all linux snapshot builds going back to the 5.10 snapshot from Jan. 2 last year. If I go back to the 2023 builds, the repro repo has other compilation failures for those older compilers, so it doesn't even get to this snippet that causes a compiler crash. I don't see the crash with the Swift 6.0.3 release, presumably because those simply have these assertions turned off. Looks like this is one of four "Found outside of lifetime use?!" crashes reported going back more than two years, with another four closed. @atrick, can you take a look at this? @tayloraswift, you may want to start running your repos through a CI including the snapshot builds, as you could've reported this at least a year ago. @fibrechannelscsi, that appears to be a different issue, if you cannot reproduce with the Swift 6.1 snapshot from this month. I suggest you bisect the 6.1 snapshots and see if you can find what pull fixed that, then check if it's already backported to the release/6.0 branch or needs to be for the next patch release. |
imo, this should be the responsibility of the Swift Source Compatibility Suite. that project desperately needs to be revived. https://forums.swift.org/t/is-the-swift-source-compatibility-suite-still-maintained/77191 |
I've made a new ticket for this issue here: This appears to be a 6.0-only issue; I haven't found any 6.1-series toolchains with this crash. |
Description
While getting a Swift package working on Android (tayloraswift/swift-jpeg#30), I encountered a crash when cross-compiling from to Android using the 6.0.2 Android SDK.
The curious thing is that it only crashes when using the macOS OSS 6.0.2 toolchain to perform the cross-compilation, whereas it does not crash when using the Linux 6.0.2 toolchain (with the exact same Android SDK). You can see this in the Action run at https://github.com/marcprux/swift-property-crash/actions/runs/12638581877/job/35215154371.
Reproduction
On an macOS 15 machine, set up the Android cross-compiler either manually (https://github.com/finagolfin/swift-android-sdk/blob/main/README.md) or using Skip's support (
brew install skiptools/skip/skip
thenskip android sdk install --version 6.0.2
), then checkout https://github.com/marcprux/swift-property-crash.git and attempt to build.E.g.:
I haven't narrowed this down to a small test case, but the crash is resolved by changing:
to:
Stack dump
Expected behavior
The compiler should not crash.
Environment
Additional information
No response
The text was updated successfully, but these errors were encountered: