Skip to content

Commit d9da975

Browse files
authored
Backports for 1.10.0-rc2 (#52045)
Backported PRs: - [x] #51213 <!-- Wait for other threads to finish compiling before exiting --> - [x] #51520 <!-- Make allocopt respect the GC verifier rules with non usual address spaces --> - [x] #51598 <!-- Use a simple error when reporting sysimg load failures. --> - [x] #51757 <!-- fix parallel peakflop usage --> - [x] #51781 <!-- Don't make pkgimages global editable --> - [x] #51848 <!-- allow finalizers to take any locks and yield during exit --> - [x] #51847 <!-- add missing wait during Timer and AsyncCondition close --> - [x] #50824 <!-- Add some aliasing warnings to docstrings for mutating functions in Base --> - [x] #51885 <!-- remove chmodding the pkgimages --> - [x] #50207 <!-- [devdocs] Improve documentation about building external forks of LLVM --> - [x] #51967 <!-- further fix to the new promoting method for AbstractDateTime subtraction --> - [x] #51980 <!-- macroexpand: handle const/atomic struct fields correctly --> - [x] #51995 <!-- [Artifacts] Pass artifacts dictionary to `ensure_artifact_installed` dispatch --> - [x] #52098 <!-- Fix errors in `sort` docstring --> - [x] #52136 <!-- Bump JuliaSyntax to 0.4.7 --> - [x] #52140 <!-- Make c func `abspath` consistent on Windows. Fix tracking path conversion. --> - [x] #52009 <!-- fix completion that resulted in startpos of 0 for `\\ --> - [x] #52192 <!-- cap the number of GC threads to number of cpu cores --> - [x] #52206 <!-- Make have_fma consistent between interpreter and compiled --> - [x] #52027 <!-- fix Unicode.julia_chartransform for Julia 1.10 --> - [x] #52217 <!-- More helpful error message for empty `cpu_target` in `Base.julia_cmd` --> - [x] #51371 <!-- Memoize `cwstring` when used for env lookup / modification on Windows --> - [x] #52214 <!-- Turn Method Overwritten Error into a PrecompileError -- turning off caching --> - [x] #51895 <!-- Devdocs on fixing precompile hangs, take 2 --> - [x] #51596 <!-- Reland "Don't mark nonlocal symbols as hidden"" --> - [x] #51834 <!-- [REPLCompletions] allow symbol completions within incomplete macrocall expression --> - [x] #52010 <!-- Revert "Support sorting iterators (#46104)" --> - [x] #51430 <!-- add support for async backtraces of Tasks on any thread --> - [x] #51471 <!-- Fix segfault if root task is NULL --> - [x] #52194 <!-- Fix multiversioning issues caused by the parallel llvm work --> - [x] #51035 <!-- refactor GC scanning code to reflect jl_binding_t are now first class --> - [x] #52030 <!-- Bump Statistics --> - [x] #52189 <!-- codegen: ensure i1 bool is widened to i8 before storing --> - [x] #52228 <!-- Widen diagonal var during `Type` unwrapping in `instanceof_tfunc` --> - [x] #52182 <!-- jitlayers: replace sharedbytes intern pool with one that respects alignment --> Contains multiple commits, manual intervention needed: - [ ] #51092 <!-- inference: fix bad effects for recursion --> Non-merged PRs with backport label: - [ ] #52196 <!-- Fix creating custom log level macros --> - [ ] #52170 <!-- fix invalidations related to `ismutable` --> - [ ] #51479 <!-- prevent code loading from lookin in the versioned environment when building Julia -->
2 parents 5aaa948 + b497f44 commit d9da975

File tree

96 files changed

+1722
-722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1722
-722
lines changed

Make.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ USE_MLIR := 0
359359
# Options to use RegionVectorizer
360360
USE_RV := 0
361361

362+
# Use `ccache` for speeding up recompilation of the C/C++ part of Julia.
363+
# Requires the `ccache` executable to be in the `PATH` environment variable.
364+
USECCACHE := 0
365+
362366
# Cross-compile
363367
#XC_HOST := i686-w64-mingw32
364368
#XC_HOST := x86_64-w64-mingw32

base/Base.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ time_ns() = ccall(:jl_hrtime, UInt64, ())
115115

116116
start_base_include = time_ns()
117117

118+
# A warning to be interpolated in the docstring of every dangerous mutating function in Base, see PR #50824
119+
const _DOCS_ALIASING_WARNING = """
120+
!!! warning
121+
Behavior can be unexpected when any mutated argument shares memory with any other argument.
122+
"""
123+
118124
## Load essential files and libraries
119125
include("essentials.jl")
120126
include("ctypes.jl")

base/abstractarray.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,8 @@ If `dst` and `src` are of the same type, `dst == src` should hold after
905905
the call. If `dst` and `src` are multidimensional arrays, they must have
906906
equal [`axes`](@ref).
907907
908+
$(_DOCS_ALIASING_WARNING)
909+
908910
See also [`copyto!`](@ref).
909911
910912
!!! compat "Julia 1.1"
@@ -1369,6 +1371,8 @@ _unsafe_ind2sub(sz, i) = (@inline; _ind2sub(sz, i))
13691371
Store values from array `X` within some subset of `A` as specified by `inds`.
13701372
The syntax `A[inds...] = X` is equivalent to `(setindex!(A, X, inds...); X)`.
13711373
1374+
$(_DOCS_ALIASING_WARNING)
1375+
13721376
# Examples
13731377
```jldoctest
13741378
julia> A = zeros(2,2);
@@ -1587,10 +1591,14 @@ eltypeof(x::AbstractArray) = eltype(x)
15871591
promote_eltypeof() = error()
15881592
promote_eltypeof(v1) = eltypeof(v1)
15891593
promote_eltypeof(v1, vs...) = promote_type(eltypeof(v1), promote_eltypeof(vs...))
1594+
promote_eltypeof(v1::T, vs::T...) where {T} = eltypeof(v1)
1595+
promote_eltypeof(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T
15901596

15911597
promote_eltype() = error()
15921598
promote_eltype(v1) = eltype(v1)
15931599
promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...))
1600+
promote_eltype(v1::T, vs::T...) where {T} = eltype(T)
1601+
promote_eltype(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T
15941602

15951603
#TODO: ERROR CHECK
15961604
_cat(catdim::Int) = Vector{Any}()
@@ -3339,6 +3347,8 @@ end
33393347
Like [`map`](@ref), but stores the result in `destination` rather than a new
33403348
collection. `destination` must be at least as large as the smallest collection.
33413349
3350+
$(_DOCS_ALIASING_WARNING)
3351+
33423352
See also: [`map`](@ref), [`foreach`](@ref), [`zip`](@ref), [`copyto!`](@ref).
33433353
33443354
# Examples

base/abstractset.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const ∪ = union
6565
Construct the [`union`](@ref) of passed in sets and overwrite `s` with the result.
6666
Maintain order with arrays.
6767
68+
$(_DOCS_ALIASING_WARNING)
69+
6870
# Examples
6971
```jldoctest
7072
julia> a = Set([3, 4, 5]);
@@ -182,6 +184,8 @@ const ∩ = intersect
182184
183185
Intersect all passed in sets and overwrite `s` with the result.
184186
Maintain order with arrays.
187+
188+
$(_DOCS_ALIASING_WARNING)
185189
"""
186190
function intersect!(s::AbstractSet, itrs...)
187191
for x in itrs
@@ -218,6 +222,8 @@ setdiff(s) = union(s)
218222
Remove from set `s` (in-place) each element of each iterable from `itrs`.
219223
Maintain order with arrays.
220224
225+
$(_DOCS_ALIASING_WARNING)
226+
221227
# Examples
222228
```jldoctest
223229
julia> a = Set([1, 3, 4, 5]);
@@ -272,6 +278,8 @@ symdiff(s) = symdiff!(copy(s))
272278
Construct the symmetric difference of the passed in sets, and overwrite `s` with the result.
273279
When `s` is an array, the order is maintained.
274280
Note that in this case the multiplicity of elements matters.
281+
282+
$(_DOCS_ALIASING_WARNING)
275283
"""
276284
function symdiff!(s::AbstractSet, itrs...)
277285
for x in itrs

base/accumulate.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ end
4242
cumsum!(B, A; dims::Integer)
4343
4444
Cumulative sum of `A` along the dimension `dims`, storing the result in `B`. See also [`cumsum`](@ref).
45+
46+
$(_DOCS_ALIASING_WARNING)
4547
"""
4648
cumsum!(B::AbstractArray{T}, A; dims::Integer) where {T} =
4749
accumulate!(add_sum, B, A, dims=dims)
@@ -150,6 +152,8 @@ cumsum(itr) = accumulate(add_sum, itr)
150152
151153
Cumulative product of `A` along the dimension `dims`, storing the result in `B`.
152154
See also [`cumprod`](@ref).
155+
156+
$(_DOCS_ALIASING_WARNING)
153157
"""
154158
cumprod!(B::AbstractArray{T}, A; dims::Integer) where {T} =
155159
accumulate!(mul_prod, B, A, dims=dims)
@@ -159,6 +163,8 @@ cumprod!(B::AbstractArray{T}, A; dims::Integer) where {T} =
159163
160164
Cumulative product of a vector `x`, storing the result in `y`.
161165
See also [`cumprod`](@ref).
166+
167+
$(_DOCS_ALIASING_WARNING)
162168
"""
163169
cumprod!(y::AbstractVector, x::AbstractVector) = cumprod!(y, x, dims=1)
164170

@@ -301,6 +307,8 @@ Cumulative operation `op` on `A` along the dimension `dims`, storing the result
301307
Providing `dims` is optional for vectors. If the keyword argument `init` is given, its
302308
value is used to instantiate the accumulation.
303309
310+
$(_DOCS_ALIASING_WARNING)
311+
304312
See also [`accumulate`](@ref), [`cumsum!`](@ref), [`cumprod!`](@ref).
305313
306314
# Examples

base/array.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ source and `do` in the destination (1-indexed).
322322
The `unsafe` prefix on this function indicates that no validation is performed to ensure
323323
that N is inbounds on either array. Incorrect usage may corrupt or segfault your program, in
324324
the same manner as C.
325+
326+
$(_DOCS_ALIASING_WARNING)
325327
"""
326328
function unsafe_copyto!(dest::Array{T}, doffs, src::Array{T}, soffs, n) where T
327329
t1 = @_gc_preserve_begin dest
@@ -1781,6 +1783,8 @@ place of the removed items; in this case, `indices` must be a `AbstractUnitRange
17811783
To insert `replacement` before an index `n` without removing any items, use
17821784
`splice!(collection, n:n-1, replacement)`.
17831785
1786+
$(_DOCS_ALIASING_WARNING)
1787+
17841788
!!! compat "Julia 1.5"
17851789
Prior to Julia 1.5, `indices` must always be a `UnitRange`.
17861790
@@ -2760,6 +2764,8 @@ Remove the items at all the indices which are not given by `inds`,
27602764
and return the modified `a`.
27612765
Items which are kept are shifted to fill the resulting gaps.
27622766
2767+
$(_DOCS_ALIASING_WARNING)
2768+
27632769
`inds` must be an iterator of sorted and unique integer indices.
27642770
See also [`deleteat!`](@ref).
27652771

base/asyncevent.jl

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,26 @@ end
118118
unsafe_convert(::Type{Ptr{Cvoid}}, t::Timer) = t.handle
119119
unsafe_convert(::Type{Ptr{Cvoid}}, async::AsyncCondition) = async.handle
120120

121+
# if this returns true, the object has been signaled
122+
# if this returns false, the object is closed
121123
function _trywait(t::Union{Timer, AsyncCondition})
122124
set = t.set
123125
if set
124126
# full barrier now for AsyncCondition
125127
t isa Timer || Core.Intrinsics.atomic_fence(:acquire_release)
126128
else
127-
t.isopen || return false
128-
t.handle == C_NULL && return false
129+
if !isopen(t)
130+
close(t) # wait for the close to complete
131+
return false
132+
end
129133
iolock_begin()
130134
set = t.set
131135
if !set
132136
preserve_handle(t)
133137
lock(t.cond)
134138
try
135139
set = t.set
136-
if !set && t.isopen && t.handle != C_NULL
140+
if !set && t.handle != C_NULL # wait for set or handle, but not the isopen flag
137141
iolock_end()
138142
set = wait(t.cond)
139143
unlock(t.cond)
@@ -160,10 +164,28 @@ end
160164
isopen(t::Union{Timer, AsyncCondition}) = t.isopen && t.handle != C_NULL
161165

162166
function close(t::Union{Timer, AsyncCondition})
167+
t.handle == C_NULL && return # short-circuit path
163168
iolock_begin()
164-
if isopen(t)
165-
@atomic :monotonic t.isopen = false
166-
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), t)
169+
if t.handle != C_NULL
170+
if t.isopen
171+
@atomic :monotonic t.isopen = false
172+
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), t)
173+
end
174+
# implement _trywait here without the auto-reset function, just waiting for the final close signal
175+
preserve_handle(t)
176+
lock(t.cond)
177+
try
178+
while t.handle != C_NULL
179+
iolock_end()
180+
wait(t.cond)
181+
unlock(t.cond)
182+
iolock_begin()
183+
lock(t.cond)
184+
end
185+
finally
186+
unlock(t.cond)
187+
unpreserve_handle(t)
188+
end
167189
end
168190
iolock_end()
169191
nothing
@@ -220,7 +242,10 @@ function uv_timercb(handle::Ptr{Cvoid})
220242
@atomic :monotonic t.set = true
221243
if ccall(:uv_timer_get_repeat, UInt64, (Ptr{Cvoid},), t) == 0
222244
# timer is stopped now
223-
close(t)
245+
if t.isopen
246+
@atomic :monotonic t.isopen = false
247+
ccall(:jl_close_uv, Cvoid, (Ptr{Cvoid},), t)
248+
end
224249
end
225250
notify(t.cond, true)
226251
finally

base/asyncmap.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ length(itr::AsyncGenerator) = length(itr.collector.enumerator)
394394
395395
Like [`asyncmap`](@ref), but stores output in `results` rather than
396396
returning a collection.
397+
398+
$(_DOCS_ALIASING_WARNING)
397399
"""
398400
function asyncmap!(f, r, c1, c...; ntasks=0, batch_size=nothing)
399401
foreach(identity, AsyncCollector(f, r, c1, c...; ntasks=ntasks, batch_size=batch_size))

base/boot.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ struct InitError <: WrappedException
370370
error
371371
end
372372

373+
struct PrecompilableError <: Exception end
374+
373375
String(s::String) = s # no constructor yet
374376

375377
const Cvoid = Nothing

base/combinatorics.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ it is even faster to write into a pre-allocated output array with `u .= @view v[
169169
(Even though `permute!` overwrites `v` in-place, it internally requires some allocation
170170
to keep track of which elements have been moved.)
171171
172+
$(_DOCS_ALIASING_WARNING)
173+
172174
See also [`invpermute!`](@ref).
173175
174176
# Examples
@@ -222,6 +224,8 @@ Note that if you have a pre-allocated output array (e.g. `u = similar(v)`),
222224
it is quicker to instead employ `u[p] = v`. (`invpermute!` internally
223225
allocates a copy of the data.)
224226
227+
$(_DOCS_ALIASING_WARNING)
228+
225229
# Examples
226230
```jldoctest
227231
julia> A = [1, 1, 3, 4];

0 commit comments

Comments
 (0)