mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-12-05 06:14:18 +01:00
If the build server reports a dependency cycle, the worklist in targetDepthsAndDependents kept pushing targets around the cycle forever. It spun the BuildServerManager actor at 100% CPU, grew memory without bound, and finally aborted with a retain-count overflow. Walk the targets in topological order instead. When the walk gets stuck on a cycle, break it at the target where the cycle is entered and ignore the edges that lead back into it. Every edge is considered once, so this finishes on any graph, and targets in or below a cycle still get depths that put them after the targets that depend on them.