Skip to content

Commit 0bd77f5

Browse files
vtjnashKristofferC
authored andcommitted
[REPL] fix lock ordering mistake in load_pkg (#56215)
Fixes #56206 (cherry picked from commit 1f935af)
1 parent b27d83e commit 0bd77f5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

base/loading.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,6 +2044,7 @@ debug_loading_deadlocks::Bool = true # Enable a slightly more expensive, but mor
20442044
function start_loading(modkey::PkgId, build_id::UInt128, stalecheck::Bool)
20452045
# handle recursive and concurrent calls to require
20462046
assert_havelock(require_lock)
2047+
require_lock.reentrancy_cnt == 1 || throw(ConcurrencyViolationError("recursive call to start_loading"))
20472048
while true
20482049
loaded = stalecheck ? maybe_root_module(modkey) : nothing
20492050
loaded isa Module && return loaded

stdlib/REPL/src/Pkg_beforeload.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
## Pkg stuff needed before Pkg has loaded
22

33
const Pkg_pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")
4-
const Pkg_REPLExt_pkgid = Base.PkgId(Base.UUID("ceef7b17-42e7-5b1c-81d4-4cc4a2494ccf"), "REPLExt")
54

65
function load_pkg()
6+
REPLExt = Base.require_stdlib(Pkg_pkgid, "REPLExt")
77
@lock Base.require_lock begin
8-
REPLExt = Base.require_stdlib(Pkg_pkgid, "REPLExt")
98
# require_stdlib does not guarantee that the `__init__` of the package is done when loading is done async
109
# but we need to wait for the repl mode to be set up
11-
lock = get(Base.package_locks, Pkg_REPLExt_pkgid.uuid, nothing)
10+
lock = get(Base.package_locks, Base.PkgId(REPLExt), nothing)
1211
lock !== nothing && wait(lock[2])
13-
return REPLExt
1412
end
13+
return REPLExt
1514
end
1615

1716
## Below here copied/tweaked from Pkg Types.jl so that the dummy Pkg prompt

0 commit comments

Comments
 (0)