Skip to content
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

Backports for Julia 1.11.0-rc2 #54925

Merged
merged 36 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c3a21a2
set VERSION to 1.11.0-rc1
KristofferC Jun 25, 2024
30c4d49
LazyString in interpolated error messages in threadingconstructs (#54…
jishnub Jun 24, 2024
d728558
remove `wrap` from NEWS and docs since it was made private
KristofferC Jun 25, 2024
6cf82f9
Revert "Revert "Cleanup MemoryRef tests (#54681)""
KristofferC Jun 25, 2024
b7af64f
1.11: improve type stability of `_unsafe_take!(::IOBuffer)` (#54942)
aviatesk Jun 27, 2024
74cead1
inference: add missing `MustAlias` widening in `_getfield_tfunc` (#54…
aviatesk Jul 2, 2024
744b24d
Create `jl_clear_coverage_data` to dynamically reset coverage (#54358)
MilesCranmer May 24, 2024
b3b0416
LAPACK: Avoid repr call in `chkvalidparam` (#54952)
jishnub Jun 27, 2024
4929aa2
fix concurrent module loading return value (#54898)
vtjnash Jul 7, 2024
7e5214d
Add fast method for copyto!(::Memory, ::Memory) (#55082)
jakobnissen Jul 9, 2024
2314ea6
Use triple quotes in TOML.print when string contains newline (#55084)
palday Jul 9, 2024
c84b516
LinearAlgebra: use `≈` instead of `==` for `tr` tests in symmetric.jl…
aviatesk Jul 17, 2024
b5c04a4
Fix generic triangular solves with empty matrices (#54201)
dkarrasch Apr 23, 2024
d9906cf
Update the aarch64 devdocs to reflect the current state of its suppor…
gbaraldi Jul 16, 2024
2bc291a
don't throw EOFError from sleep (#54955)
lgeissbauer-btig Jul 17, 2024
f9b3b7f
Make warn missed transformations pass optional (#54871)
lcw Jul 18, 2024
a02dbac
Compat for `Base.@nospecializeinfer` (#55178)
mikmoore Jul 20, 2024
93e086f
compat notice for a[begin] indexing (#55197)
stevengj Jul 21, 2024
5ba19c1
Fix potential underrun with annotation merging (#54917)
tecosaur Jul 22, 2024
35f56b1
correction to compat notice for a[begin] (#55209)
stevengj Jul 22, 2024
91976c2
document mutable struct const fields (#55203)
IanButterworth Jul 23, 2024
4e18948
Bump libblastrampoline to v5.10.1 (#54791)
staticfloat Jun 14, 2024
73353dc
SuiteSparse: Bump version (#54950)
rayegun Jun 27, 2024
54bd4b9
Fix accidental early evaluation of imported `using` binding (#54956)
Keno Jun 28, 2024
3387373
LinearAlgebra: LazyString in error messages for Diagonal/Bidiagonal (…
jishnub Jul 10, 2024
3f67b31
Raise an error when using `include_dependency` with non-existent file…
fatteneder Jun 21, 2024
11bba3b
RFC: Make `include_dependency(path; track_content=true)` the default …
fatteneder Jul 2, 2024
c42fc03
Make ScopedValues public (#54574)
LilithHafner Jul 3, 2024
19f838f
finish implementation of upgradable stdlibs (#54739)
vtjnash Jun 21, 2024
bddb4ed
#54739-related fixes for loading stdlibs (#54891)
vtjnash Jun 24, 2024
d4f9808
fix loading of repeated/concurrent modules (#55066)
vtjnash Jul 11, 2024
66ffcea
Reinstate similar for AbstractQ for backward compatibility (#52694)
jishnub May 22, 2024
6844898
bump Pkg to latest v1.11
KristofferC Jul 23, 2024
b39fd85
Make Core.TypeofUnion use the type method table (#55188)
vtjnash Jul 23, 2024
f51eeca
Artifacts: use a different way of getting the UUID of a module (#55218)
KristofferC Jul 23, 2024
c2dcb7e
remove JuliaSyntaxHighlighting from 1.11 (#55217)
KristofferC Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix concurrent module loading return value (#54898)
Previously this might return `nothing` which would confuse the caller of
`start_loading` which expects that to mean the Module didn't load. It is
not entirely clear if this code ever worked, even single-threaded.

Fix #54813

(cherry picked from commit 0ef2bb6)
  • Loading branch information
vtjnash authored and KristofferC committed Jul 12, 2024
commit 4929aa2ddf775e058188da489f423ec87e59eda0
48 changes: 25 additions & 23 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1935,8 +1935,12 @@ debug_loading_deadlocks::Bool = true # Enable a slightly more expensive, but mor
function start_loading(modkey::PkgId)
# handle recursive calls to require
assert_havelock(require_lock)
loading = get(package_locks, modkey, nothing)
if loading !== nothing
while true
loading = get(package_locks, modkey, nothing)
if loading === nothing
package_locks[modkey] = current_task() => Threads.Condition(require_lock)
return nothing
end
# load already in progress for this module on the task
task, cond = loading
deps = String[modkey.name]
Expand Down Expand Up @@ -1975,10 +1979,9 @@ function start_loading(modkey::PkgId)
end
throw(ConcurrencyViolationError(msg))
end
return wait(cond)
loading = wait(cond)
loading isa Module && return loading
end
package_locks[modkey] = current_task() => Threads.Condition(require_lock)
return
end

function end_loading(modkey::PkgId, @nospecialize loaded)
Expand Down Expand Up @@ -2343,9 +2346,9 @@ function _require(pkg::PkgId, env=nothing)
# attempt to load the module file via the precompile cache locations
if JLOptions().use_compiled_modules != 0
@label load_from_cache
m = _require_search_from_serialized(pkg, path, UInt128(0), true; reasons)
if m isa Module
return m
loaded = _require_search_from_serialized(pkg, path, UInt128(0), true; reasons)
if loaded isa Module
return loaded
end
end

Expand Down Expand Up @@ -2381,31 +2384,30 @@ function _require(pkg::PkgId, env=nothing)
@goto load_from_cache
end
# spawn off a new incremental pre-compile task for recursive `require` calls
cachefile_or_module = maybe_cachefile_lock(pkg, path) do
# double-check now that we have lock
loaded = maybe_cachefile_lock(pkg, path) do
# double-check the search now that we have lock
m = _require_search_from_serialized(pkg, path, UInt128(0), true)
m isa Module && return m
compilecache(pkg, path; reasons)
return compilecache(pkg, path; reasons)
end
cachefile_or_module isa Module && return cachefile_or_module::Module
cachefile = cachefile_or_module
if isnothing(cachefile) # maybe_cachefile_lock returns nothing if it had to wait for another process
loaded isa Module && return loaded
if isnothing(loaded) # maybe_cachefile_lock returns nothing if it had to wait for another process
@goto load_from_cache # the new cachefile will have the newest mtime so will come first in the search
elseif isa(cachefile, Exception)
if precompilableerror(cachefile)
elseif isa(loaded, Exception)
if precompilableerror(loaded)
verbosity = isinteractive() ? CoreLogging.Info : CoreLogging.Debug
@logmsg verbosity "Skipping precompilation due to precompilable error. Importing $(repr("text/plain", pkg))." exception=m
@logmsg verbosity "Skipping precompilation due to precompilable error. Importing $(repr("text/plain", pkg))." exception=loaded
else
@warn "The call to compilecache failed to create a usable precompiled cache file for $(repr("text/plain", pkg))" exception=m
@warn "The call to compilecache failed to create a usable precompiled cache file for $(repr("text/plain", pkg))" exception=loaded
end
# fall-through to loading the file locally if not incremental
else
cachefile, ocachefile = cachefile::Tuple{String, Union{Nothing, String}}
m = _tryrequire_from_serialized(pkg, cachefile, ocachefile)
if !isa(m, Module)
@warn "The call to compilecache failed to create a usable precompiled cache file for $(repr("text/plain", pkg))" exception=m
cachefile, ocachefile = loaded::Tuple{String, Union{Nothing, String}}
loaded = _tryrequire_from_serialized(pkg, cachefile, ocachefile)
if !isa(loaded, Module)
@warn "The call to compilecache failed to create a usable precompiled cache file for $(repr("text/plain", pkg))" exception=loaded
else
return m
return loaded
end
end
if JLOptions().incremental != 0
Expand Down
17 changes: 11 additions & 6 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,11 @@ end
empty!(Base.DEPOT_PATH)
append!(Base.DEPOT_PATH, original_depot_path)

module loaded_pkgid1 end
module loaded_pkgid2 end
module loaded_pkgid3 end
module loaded_pkgid4 end

@testset "loading deadlock detector" begin
pkid1 = Base.PkgId("pkgid1")
pkid2 = Base.PkgId("pkgid2")
Expand All @@ -1217,25 +1222,25 @@ append!(Base.DEPOT_PATH, original_depot_path)
t1 = @async begin
@test nothing === @lock Base.require_lock Base.start_loading(pkid2) # @async module pkgid2; using pkgid1; end
notify(e)
@test "loaded_pkgid1" == @lock Base.require_lock Base.start_loading(pkid1)
@lock Base.require_lock Base.end_loading(pkid2, "loaded_pkgid2")
@test loaded_pkgid1 == @lock Base.require_lock Base.start_loading(pkid1)
@lock Base.require_lock Base.end_loading(pkid2, loaded_pkgid2)
end
wait(e)
reset(e)
t2 = @async begin
@test nothing === @lock Base.require_lock Base.start_loading(pkid3) # @async module pkgid3; using pkgid2; end
notify(e)
@test "loaded_pkgid2" == @lock Base.require_lock Base.start_loading(pkid2)
@lock Base.require_lock Base.end_loading(pkid3, "loaded_pkgid3")
@test loaded_pkgid2 == @lock Base.require_lock Base.start_loading(pkid2)
@lock Base.require_lock Base.end_loading(pkid3, loaded_pkgid3)
end
wait(e)
reset(e)
@test_throws(ConcurrencyViolationError("deadlock detected in loading pkgid3 -> pkgid2 -> pkgid1 -> pkgid3 && pkgid4"),
@lock Base.require_lock Base.start_loading(pkid3)).value # try using pkgid3
@test_throws(ConcurrencyViolationError("deadlock detected in loading pkgid4 -> pkgid4 && pkgid1"),
@lock Base.require_lock Base.start_loading(pkid4)).value # try using pkgid4
@lock Base.require_lock Base.end_loading(pkid1, "loaded_pkgid1") # end
@lock Base.require_lock Base.end_loading(pkid4, "loaded_pkgid4") # end
@lock Base.require_lock Base.end_loading(pkid1, loaded_pkgid1) # end
@lock Base.require_lock Base.end_loading(pkid4, loaded_pkgid4) # end
wait(t2)
wait(t1)
end
Expand Down
8 changes: 5 additions & 3 deletions test/threads_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1122,23 +1122,25 @@ end

# issue #41546, thread-safe package loading
@testset "package loading" begin
ch = Channel{Bool}(threadpoolsize())
ntasks = max(threadpoolsize(), 4)
ch = Channel{Bool}(ntasks)
barrier = Base.Event()
old_act_proj = Base.ACTIVE_PROJECT[]
try
pushfirst!(LOAD_PATH, "@")
Base.ACTIVE_PROJECT[] = joinpath(@__DIR__, "TestPkg")
@sync begin
for _ in 1:threadpoolsize()
for _ in 1:ntasks
Threads.@spawn begin
put!(ch, true)
wait(barrier)
@eval using TestPkg
end
end
for _ in 1:threadpoolsize()
for _ in 1:ntasks
take!(ch)
end
close(ch)
notify(barrier)
end
@test Base.root_module(@__MODULE__, :TestPkg) isa Module
Expand Down