Commit 6fd66c7
committed
cmd/dist: detect import cycles instead of deadlocking
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 each dependency by
tracking an "install stack" of which package is waiting on which.
Before waiting for a dependency, we walk the stack to check if that
dependency is already waiting on us. When a cycle is detected, we
report it with a clear message like "import cycle: A -> B -> A".
Fixes #764391 parent 65b71c1 commit 6fd66c7
1 file changed
+45
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
681 | 685 | | |
682 | 686 | | |
683 | 687 | | |
| |||
883 | 887 | | |
884 | 888 | | |
885 | 889 | | |
| 890 | + | |
| 891 | + | |
886 | 892 | | |
887 | 893 | | |
888 | 894 | | |
889 | 895 | | |
| 896 | + | |
890 | 897 | | |
891 | 898 | | |
892 | | - | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
893 | 933 | | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
894 | 938 | | |
895 | 939 | | |
896 | 940 | | |
| |||
0 commit comments