@@ -2178,7 +2178,6 @@ function canstart_loading(modkey::PkgId, build_id::UInt128, stalecheck::Bool)
21782178 # load already in progress for this module on the task
21792179 task, cond = loading
21802180 deps = String[modkey. name]
2181- pkgid = modkey
21822181 assert_havelock (cond. lock)
21832182 if debug_loading_deadlocks && current_task () != = task
21842183 waiters = Dict {Task,Pair{Task,PkgId}} () # invert to track waiting tasks => loading tasks
@@ -2198,18 +2197,26 @@ function canstart_loading(modkey::PkgId, build_id::UInt128, stalecheck::Bool)
21982197 end
21992198 end
22002199 if current_task () === task
2201- others = String[modkey. name] # repeat this to emphasize the cycle here
2200+ push! (deps, modkey. name) # repeat this to emphasize the cycle here
2201+ others = Set {String} ()
22022202 for each in package_locks # list the rest of the packages being loaded too
22032203 if each[2 ][1 ] === task
22042204 other = each[1 ]. name
2205- other == modkey. name || other == pkgid . name || push! (others, other)
2205+ other == modkey. name || push! (others, other)
22062206 end
22072207 end
2208+ # remove duplicates from others already in deps
2209+ for dep in deps
2210+ delete! (others, dep)
2211+ end
22082212 msg = sprint (deps, others) do io, deps, others
22092213 print (io, " deadlock detected in loading " )
2210- join (io, deps, " -> " )
2211- print (io, " -> " )
2212- join (io, others, " && " )
2214+ join (io, deps, " using " )
2215+ if ! isempty (others)
2216+ print (io, " (while loading " )
2217+ join (io, others, " and " )
2218+ print (io, " )" )
2219+ end
22132220 end
22142221 throw (ConcurrencyViolationError (msg))
22152222 end
0 commit comments