-
Notifications
You must be signed in to change notification settings - Fork 18.7k
cmd/dist: detect import cycles instead of deadlocking #76862
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
base: master
Are you sure you want to change the base?
cmd/dist: detect import cycles instead of deadlocking #76862
Conversation
Previously, if there was an import cycle in the packages being built (e.g., package A imports B and B imports A), the build would deadlock with "all goroutines are asleep - deadlock!" because each package's goroutine would block waiting for the other to complete. Now we detect import cycles before blocking on dependencies by tracking which packages each goroutine is waiting on and checking for cycles using depth-first search. When a cycle is detected, we report it with a clear message, for example: "import cycle: go/ast -> go/token -> go/ast" Fixes golang#76439
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
This PR (HEAD: a4e4a2a) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/730620. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/730620. |
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/730620. |
|
Message from Michael Matloob: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/730620. |
|
Message from Funda Secgin: Patch Set 1: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/730620. |
Summary
Previously, if there was an import cycle in the packages being built (e.g., package A imports B and B imports A), the build would deadlock with "all goroutines are asleep - deadlock!" because each package's goroutine would block waiting for the other to complete.
Now we detect import cycles before blocking on dependencies by tracking which packages each goroutine is waiting on and checking for cycles using depth-first search. When a cycle is detected, we report it with a clear message:
import cycle: go/ast -> go/astimport cycle: go/ast -> go/scanner -> go/token -> go/astTest plan
all.bashpasses: ALL TESTS PASSEDFixes #76439