-
Notifications
You must be signed in to change notification settings - Fork 112
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
Production hang updating from 1.1.5 to 1.2.x #199
Comments
Ok, I've found the issue via a stand-alone reproducer: https://github.com/finestructure/dependencies-hang-repro The problem was that we still used an "old style" entrypoint to run an async import Foundation
let group = DispatchGroup()
group.enter()
Task {
defer { group.leave() }
await Builder.main()
}
group.wait() Once I change this to @main
struct Executable {
static func main() async throws {
await Builder.main()
}
} the hang disappears. This is certainly our bug (I'm unsure if the |
Hi @finestructure, it's most likely related to this PR #169. In general, because we need to do threading shenanigans in However, curious why spin up the @main
struct Executable {
static func main() throws {
let group = DispatchGroup()
group.enter()
Task {
defer { group.leave() }
await Builder.main()
}
group.wait()
}
} |
This main file was from before it supported top level async code! That’s how we ended up with that DispatchGroup :) |
Description
I'll admit this is a very weird one and I'm not sure where to start to debug it but it's a reproducible production affecting issue.
In our SPI build system we build a "builder" binary using Xcode 15.3 (Swift 5.10) and distribute it to Macs that run it to build packages with various Swift versions and platforms. We have a integration test matrix set up to run a package build for all combinations.
When I do a package update for our builder, updating swift-dependencies from 1.1.5 to 1.2.x (or main) causes a hang in the builder process. I.e. our package builds time out after 10min. This hang is only happening on macOS, Linux is working fine.
Our (closed source) builder doesn't use
@Dependency
itself but transitively via the open source package DocUploader.I can tell from the logs that it's hitting
@Dependency(\.uuid) var uuid
. And indeed if I replace this withlet uuid = { UUID() }
the hang disappears. (There's a second@Dependency
in the project but our test doesn't cover it, so it's unknown if it would hang, too.)Is there anything in the 1.1.5...1.2.0 diff that could cause a hang like this on macOS?
I see a couple of
#if _runtime(_ObjC)
blocks that do things withDispatchQueue
that seem likely candidates but I can't tell how they're used or if they could in fact be the cause.FWIW, we have a unit test in our builder which should be doing the same as the integration test is not hanging. I've also tried running the builder with a
-c debug
build and it's still hanging. So it's happening in both debug and release builds but not when the dependency is being replaced viawithDependencies
.I'm not sure how I could debug this further but I do have a reproducer set up that can turn around results in ~5mins. I'll see if I can boil this down into a reproducer that's less complicated to run that I can share.
For now I'm working around the issue via
which is of course not ideal but I at least I don't need to pin swift-dependencies to 1.1.5.
Checklist
main
branch of this package.Expected behavior
It should not hang 😄
Actual behavior
It hangs 😞
Steps to reproduce
Currently only internally reproducible, working on a sharable project.
Dependencies version information
1.2.x
Destination operating system
macOS 14
Xcode version information
15.3
Swift Compiler version information
The text was updated successfully, but these errors were encountered: