From 5721fdac9de30f2d03bbdece1e68f0ea5ccaadb6 Mon Sep 17 00:00:00 2001 From: Kiran Pamnany Date: Mon, 17 Jun 2024 21:48:49 -0400 Subject: [PATCH 01/19] Add boundscheck in speccache_eq to avoid OOB access due to data race (#54840) Like https://github.com/JuliaLang/julia/pull/54671, but for `speccache_eq`. Saw another segfault with this in the stack trace, hence this fix. I also looked for other uses of `jl_smallintset_lookup` and there's one in `idset.c`. That doesn't appear to be racy but I'm not familiar with the code, so maybe you can take a look at it in case we need to push a fix for that one too @gbaraldi or @vtjnash? (cherry picked from commit dd1ed17ae3c2e4e257f2444bbafd705326b4bbbd) --- src/gf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gf.c b/src/gf.c index c9e7391b2fd8a..8f8b128e951ce 100644 --- a/src/gf.c +++ b/src/gf.c @@ -113,7 +113,7 @@ static int8_t jl_cachearg_offset(jl_methtable_t *mt) static uint_t speccache_hash(size_t idx, jl_value_t *data) { - jl_method_instance_t *ml = (jl_method_instance_t*)jl_svecref(data, idx); + jl_method_instance_t *ml = (jl_method_instance_t*)jl_svecref(data, idx); // This must always happen inside the lock jl_value_t *sig = ml->specTypes; if (jl_is_unionall(sig)) sig = jl_unwrap_unionall(sig); @@ -122,6 +122,8 @@ static uint_t speccache_hash(size_t idx, jl_value_t *data) static int speccache_eq(size_t idx, const void *ty, jl_value_t *data, uint_t hv) { + if (idx >= jl_svec_len(data)) + return 0; // We got a OOB access, probably due to a data race jl_method_instance_t *ml = (jl_method_instance_t*)jl_svecref(data, idx); jl_value_t *sig = ml->specTypes; if (ty == sig) From 5361f7c3ba55baa4f4bb1b0effa4092d2cf92469 Mon Sep 17 00:00:00 2001 From: adienes <51664769+adienes@users.noreply.github.com> Date: Sat, 19 Apr 2025 09:05:09 -0400 Subject: [PATCH 02/19] Switch from segfault to `zip` behavior for mismatched indices in `map!` (#56673) (cherry picked from commit 0947114d9d443e14c751ac40c9b2d8c2245d045e) --- test/abstractarray.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/abstractarray.jl b/test/abstractarray.jl index 1e52c913cfa30..de06a3537d996 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -909,6 +909,26 @@ generic_map_tests(map, map!) # @test_throws BoundsError map!(+, ones(3), ones(2, 2), ones(2, 2)) end +@testset "#30624" begin + ### unstructured + @test map!(+, ones(3), ones(3), ones(3), [1]) == [3, 1, 1] + @test map!(+, ones(3), [1], ones(3), ones(3)) == [3, 1, 1] + @test map!(+, [1], [1], [], []) == [1] + @test map!(+, [[1]], [1], [], []) == [[1]] + + # TODO: decide if input axes & lengths should be validated + # @test_throws BoundsError map!(+, ones(1), ones(2)) + # @test_throws BoundsError map!(+, ones(1), ones(2, 2)) + + @test map!(+, ones(3), view(ones(2, 3), 1:2, 2:3), ones(3)) == [2, 2, 2] + @test map!(+, ones(3), ones(2, 2), ones(3)) == [2, 2, 2] + + ### structured (all mapped arguments are <:AbstractArray equal ndims > 1) + @test map!(+, ones(4), ones(2, 2), ones(2, 2)) == [2, 2, 2, 2] + @test map!(+, ones(4), ones(2, 2), ones(1, 2)) == [2, 2, 1, 1] + # @test_throws BoundsError map!(+, ones(3), ones(2, 2), ones(2, 2)) +end + test_UInt_indexing(TestAbstractArray) test_13315(TestAbstractArray) test_checksquare() From 47d905df994c69f91ac416d72ec0481c1fd011da Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Wed, 4 Jun 2025 20:30:23 -0300 Subject: [PATCH 03/19] Make late gc lower handle insertelement of alloca use. (#58637) This was in DAECompiler.jl code found by @serenity4. He also mentioned that writing up how one might go and fix a bug like this so i'll give a quick writeup (this was a very simple bug so it might not be too interesting) The original crash which looked something like > %19 = alloca [10 x i64], align 8 %155 = insertelement <4 x ptr> poison, ptr %19, i32 0 Unexpected instruction > [898844] signal 6 (-6): Aborted in expression starting at /home/gbaraldi/DAECompiler.jl/test/reflection.jl:28 pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line) gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line) abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line) RecursivelyVisit, int, State&, std::map >):::: > at /home/gbaraldi/julia4/src/llvm-late-gc-lowering.cpp:803 operator() at /home/gbaraldi/julia4/src/llvm-late-gc-lowering.cpp:2560 [inlined] PlaceRootsAndUpdateCalls at /home/gbaraldi/julia4/src/llvm-late-gc-lowering.cpp:2576 runOnFunction at /home/gbaraldi/julia4/src/llvm-late-gc-lowering.cpp:2638 run at /home/gbaraldi/julia4/src/llvm-late-gc-lowering.cpp:2675 run at /home/gbaraldi/julia4/usr/include/llvm/IR/PassManagerInternal.h:91 which means it was crashing inside of late-gc-lowering, so the first thing I did was ran julia and the same test with LLVM_ASSERTIONS=1 and FORCE_ASSERTIONS=1 to see if LLVM complained about a malformed module, and both were fine. Next step was trying to get the failing code out for inspection. Easiest way is to do `export JULIA_LLVM_ARGS="--print-before=LateLowerGCFrame --print-module-scope"` and pipe the output to a file. The file is huge, but since it's a crash in LLVM we know that the last thing is what we want, and that gave me the IR I wanted. To verify that this is failing I did `make -C src install-analysis-deps` to install the LLVM machinery (opt...). That gets put in the `tools` directory of a julia build. Then I checked if this crashed outside of julia by doing `./opt -load-pass-plugin=../lib/libjulia-codegen.dylib --passes=LateLowerGCFrame -S test.ll -o tmp3.ll `. This is run from inside the tools dir so your paths might vary (the -S is so LLVM doesn't generate bitcode) and my code did crash, however it was over 500 lines of IR which makes it harder to debug and to write a test. Next step then is to minimize the crash by doing [`llvm-reduce`](https://llvm.org/docs/CommandGuide/llvm-reduce.html) over it (it's basically creduce but optimized for LLVM IR) which gave me a 2 line reproducer (in this case apparently just having the insertelement was enough for the pass to fail). One thing to be wary is that llvm-reduce will usually make very weird code, so it might be useful to modify the code slightly so it doesn't look odd (it will have unreachable basic-blocks and such). After the cleanup fixing the bug here wasn't interesting but this doesn't apply generally. And also always transform your reduced IR into a test to put in llvmpasses. (cherry picked from commit 906d3482d318868e7d3eef6b1db97ef5bedd6f82) --- src/llvm-late-gc-lowering.cpp | 2 +- test/llvmpasses/late-lower-gc.ll | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp index 8ba321c75b239..e9b63e4b5373a 100644 --- a/src/llvm-late-gc-lowering.cpp +++ b/src/llvm-late-gc-lowering.cpp @@ -1115,7 +1115,7 @@ void RecursivelyVisit(callback f, Value *V) { if (isa(TheUser) || isa(TheUser) || isa(TheUser) || isa(TheUser) || // TODO: should these be removed from this list? isa(TheUser) || isa(TheUser) || - isa(TheUser) || // ICmpEQ/ICmpNE can be used with ptr types + isa(TheUser) || isa(TheUser)|| // ICmpEQ/ICmpNE can be used with ptr types isa(TheUser) || isa(TheUser)) continue; if (isa(TheUser) || isa(TheUser) || isa(TheUser)) { diff --git a/test/llvmpasses/late-lower-gc.ll b/test/llvmpasses/late-lower-gc.ll index 62122b2ad4ec9..8f7b2523b6996 100644 --- a/test/llvmpasses/late-lower-gc.ll +++ b/test/llvmpasses/late-lower-gc.ll @@ -226,6 +226,20 @@ define void @decayar([2 x {} addrspace(10)* addrspace(11)*] %ar) { ; OPAQUE: %r = call i32 @callee_root(ptr addrspace(10) %l0, ptr addrspace(10) %l1) ; OPAQUE: call void @julia.pop_gc_frame(ptr %gcframe) +define swiftcc ptr addrspace(10) @insert_element(ptr swiftself %0) { +; CHECK-LABEL: @insert_element + %2 = alloca [10 x i64], i32 1, align 8 +; CHECK: %gcframe = call ptr @julia.new_gc_frame(i32 10) +; CHECK: [[gc_slot_addr_:%.*]] = call ptr @julia.get_gc_frame_slot(ptr %gcframe, i32 0) +; CHECK: call void @julia.push_gc_frame(ptr %gcframe, i32 10) + call void null(ptr sret([2 x [5 x ptr addrspace(10)]]) %2, ptr null, ptr addrspace(11) null, ptr null) + %4 = insertelement <4 x ptr> zeroinitializer, ptr %2, i32 0 +; CHECK: [[gc_slot_addr_:%.*]] = insertelement <4 x ptr> zeroinitializer, ptr [[gc_slot_addr_:%.*]], i32 0 +; CHECK: call void @julia.pop_gc_frame(ptr %gcframe) + ret ptr addrspace(10) null +} + + !0 = !{i64 0, i64 23} !1 = !{!1} !2 = !{!7} ; scope list From 47ebf952ea2bc46d9d27a0668edff23b0956a35d Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Tue, 10 Jun 2025 00:27:37 -0400 Subject: [PATCH 04/19] Unicode: Force-inline isgraphemebreak! (#58674) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When this API was added, this function inlined, which is important, because the API relies on the allocation of the `Ref` being elided. At some point (I went back to 1.8) this regressed. For example, it is currently responsible for substantially all non-Expr allocations in JuliaParser. Before (parsing all of Base with JuliaParser): ``` │ Memory estimate: 76.93 MiB, allocs estimate: 719922. ``` After: ``` │ Memory estimate: 53.31 MiB, allocs estimate: 156. ``` Also add a test to make sure this doesn't regress again. (cherry picked from commit d6294ba973db1dea9dc932779008fd66d27c4bd2) --- stdlib/Unicode/test/runtests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/Unicode/test/runtests.jl b/stdlib/Unicode/test/runtests.jl index 7fa57508cffbf..2af7015afa249 100644 --- a/stdlib/Unicode/test/runtests.jl +++ b/stdlib/Unicode/test/runtests.jl @@ -284,6 +284,8 @@ end @test_throws BoundsError graphemes("äöüx", 2:5) @test_throws BoundsError graphemes("äöüx", 5:5) @test_throws ArgumentError graphemes("äöüx", 0:1) + + @test @allocated(length(graphemes("äöüx"))) == 0 end @testset "#3721, #6939 up-to-date character widths" begin From 3b04664577713059bee663fb3d1cd37080a7ff8e Mon Sep 17 00:00:00 2001 From: Simeon David Schaub Date: Tue, 1 Jul 2025 16:58:39 +0200 Subject: [PATCH 05/19] fix null comparisons for non-standard address spaces (#58837) Co-authored-by: Jameson Nash (cherry picked from commit 3ed13ea7ab3d73f408b12a70ad29565c97bf5562) --- src/cgutils.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 405103076bd75..180c8fdfb0021 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -1395,10 +1395,17 @@ static void undef_var_error_ifnot(jl_codectx_t &ctx, Value *ok, jl_sym_t *name, ctx.builder.SetInsertPoint(ifok); } +// ctx.builder.CreateIsNotNull(v) lowers incorrectly in non-standard +// address spaces where null is not zero +// TODO: adapt to https://github.com/llvm/llvm-project/pull/131557 once merged static Value *null_pointer_cmp(jl_codectx_t &ctx, Value *v) { ++EmittedNullchecks; - return ctx.builder.CreateIsNotNull(v); + Type *T = v->getType(); + return ctx.builder.CreateICmpNE( + v, + ctx.builder.CreateAddrSpaceCast( + Constant::getNullValue(ctx.builder.getPtrTy(0)), T)); } From 01de2854a043625358f3aa7fc3d87f867eb30577 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Wed, 2 Jul 2025 10:46:19 -0700 Subject: [PATCH 06/19] Add a `similar` method for `Type{<:CodeUnits}` (#57826) Currently, `similar(::CodeUnits)` works as expected by going through the generic `AbstractArray` method. However, the fallback method hit by `similar(::Type{<:CodeUnits}, dims)` does not work, as it assumes the existence of a constructor that accepts an `UndefInitializer`. This can be made to work by defining a corresponding `similar` method that returns an `Array`. One could make a case that this is a bugfix since it was arguably a bug that this method didn't work given that `CodeUnits` is an `AbstractArray` subtype and the other `similar` methods work. If anybody buys that argument, it could be nice to backport this; it came up in some internal code that uses Arrow.jl and JSON3.jl together. (cherry picked from commit 8e524c73804a9615dd68011b2c5741947d19bbb6) --- base/strings/basic.jl | 2 ++ test/strings/basic.jl | 1 + 2 files changed, 3 insertions(+) diff --git a/base/strings/basic.jl b/base/strings/basic.jl index 438789758cfe0..522cb759e8c57 100644 --- a/base/strings/basic.jl +++ b/base/strings/basic.jl @@ -809,6 +809,8 @@ write(io::IO, s::CodeUnits) = write(io, s.s) cconvert(::Type{Ptr{T}}, s::CodeUnits{T}) where {T} = cconvert(Ptr{T}, s.s) cconvert(::Type{Ptr{Int8}}, s::CodeUnits{UInt8}) = cconvert(Ptr{Int8}, s.s) +similar(::Type{<:CodeUnits{T}}, dims::Dims) where {T} = similar(Array{T}, dims) + """ codeunits(s::AbstractString) diff --git a/test/strings/basic.jl b/test/strings/basic.jl index 955da2d7c4564..c959cad3ac973 100644 --- a/test/strings/basic.jl +++ b/test/strings/basic.jl @@ -1079,6 +1079,7 @@ let s = "∀x∃y", u = codeunits(s) @test_throws Base.CanonicalIndexError (u[1] = 0x00) @test collect(u) == b"∀x∃y" @test Base.elsize(u) == Base.elsize(typeof(u)) == 1 + @test similar(typeof(u), 3) isa Vector{UInt8} end # issue #24388 From 17c8d96135cdb63a9407c0fc44657f89a4b30925 Mon Sep 17 00:00:00 2001 From: Andy Dienes <51664769+adienes@users.noreply.github.com> Date: Wed, 2 Jul 2025 23:06:00 -0400 Subject: [PATCH 07/19] fix trailing indices stackoverflow in reinterpreted array (#58293) would fix https://github.com/JuliaLang/julia/issues/57170, fix https://github.com/JuliaLang/julia/issues/54623 @nanosoldier `runbenchmarks("array", vs=":master")` (cherry picked from commit e853a4f8bac99c6458cf3e09d95d9bea67b687e7) --- base/reinterpretarray.jl | 8 ++++---- test/reinterpretarray.jl | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/base/reinterpretarray.jl b/base/reinterpretarray.jl index d31f3ebb5dd2d..6fbe77c88f2cb 100644 --- a/base/reinterpretarray.jl +++ b/base/reinterpretarray.jl @@ -313,13 +313,13 @@ end _maybe_reshape(::IndexSCartesian2, A::ReshapedReinterpretArray, I...) = A # fallbacks -function _getindex(::IndexSCartesian2, A::AbstractArray{T,N}, I::Vararg{Int, N}) where {T,N} +function _getindex(::IndexSCartesian2, A::AbstractArray, I::Vararg{Int, N}) where {N} @_propagate_inbounds_meta - getindex(A, I...) + _getindex(IndexCartesian(), A, I...) end -function _setindex!(::IndexSCartesian2, A::AbstractArray{T,N}, v, I::Vararg{Int, N}) where {T,N} +function _setindex!(::IndexSCartesian2, A::AbstractArray, v, I::Vararg{Int, N}) where {N} @_propagate_inbounds_meta - setindex!(A, v, I...) + _setindex!(IndexCartesian(), A, v, I...) end # fallbacks for array types that use "pass-through" indexing (e.g., `IndexStyle(A) = IndexStyle(parent(A))`) # but which don't handle SCartesianIndex2 diff --git a/test/reinterpretarray.jl b/test/reinterpretarray.jl index e6381329e4ec6..1d6748a89fb19 100644 --- a/test/reinterpretarray.jl +++ b/test/reinterpretarray.jl @@ -320,6 +320,23 @@ test_many_wrappers(fill(1.0, 5, 3), (identity, wrapper)) do a_ @test r[goodinds...] == -5 end end + +let a = rand(ComplexF32, 5) + r = reinterpret(reshape, Float32, a) + ref = Array(r) + + @test r[1, :, 1] == ref[1, :] + @test r[1, :, 1, 1, 1] == ref[1, :] + @test r[1, :, UInt8(1)] == ref[1, :] + + r[2, :, 1] .= 0f0 + ref[2, :] .= 0f0 + @test r[2, :, 1] == ref[2, :] + + @test r[4] == ref[4] + @test_throws BoundsError r[1, :, 2] +end + let ar = [(1,2), (3,4)] arr = reinterpret(reshape, Int, ar) @test @inferred(IndexStyle(arr)) == Base.IndexSCartesian2{2}() @@ -607,3 +624,9 @@ let R = reinterpret(reshape, Float32, ComplexF32[1.0f0+2.0f0*im, 4.0f0+3.0f0*im] @test !isassigned(R, 5) @test Array(R)::Matrix{Float32} == [1.0f0 4.0f0; 2.0f0 3.0f0] end + +@testset "issue #54623" begin + x = 0xabcdef01234567 + @test reinterpret(reshape, UInt8, fill(x)) == [0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x00] + @test reinterpret(reshape, UInt8, [x]) == [0x67; 0x45; 0x23; 0x01; 0xef; 0xcd; 0xab; 0x00;;] +end From fc978933e245a75a1985cceeb8c421cb95496cf0 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Fri, 4 Jul 2025 14:09:57 +0200 Subject: [PATCH 08/19] Pkg: Allow configuring can_fancyprint(io::IO) using IOContext (#58887) (cherry picked from commit c0cc1e1022b780a3b7de6ad33593ef12484e46e2) --- base/precompilation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/precompilation.jl b/base/precompilation.jl index 5b9ddd076c4d1..905b931b6b8a2 100644 --- a/base/precompilation.jl +++ b/base/precompilation.jl @@ -342,7 +342,7 @@ Base.show(io::IO, err::PkgPrecompileError) = print(io, "PkgPrecompileError: ", e import Base: StaleCacheKey -can_fancyprint(io::IO) = io isa Base.TTY && (get(ENV, "CI", nothing) != "true") +can_fancyprint(io::IO) = @something(get(io, :force_fancyprint, nothing), (io isa Base.TTY && (get(ENV, "CI", nothing) != "true"))) function printpkgstyle(io, header, msg; color=:light_green) printstyled(io, header; color, bold=true) From 69bfb6b2daaadad732123e98cce35b146e01fc50 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Wed, 9 Jul 2025 16:48:45 -0400 Subject: [PATCH 09/19] Fix nthreadpools size in JLOptions (#58937) (cherry picked from commit 2349f431b1d0f97f3f06f8adc5d335b89d5f061c) --- base/options.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/options.jl b/base/options.jl index 18fa2ad92654d..296bd02111f38 100644 --- a/base/options.jl +++ b/base/options.jl @@ -9,7 +9,7 @@ struct JLOptions commands::Ptr{Ptr{UInt8}} # (e)eval, (E)print, (L)load image_file::Ptr{UInt8} cpu_target::Ptr{UInt8} - nthreadpools::Int16 + nthreadpools::Int8 nthreads::Int16 nmarkthreads::Int16 nsweepthreads::Int8 From 8c77017801995574d1cf87d386b3b3c6b1caffed Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sat, 12 Jul 2025 06:47:59 -0400 Subject: [PATCH 10/19] Fix precompilepkgs warn loaded setting (#58978) (cherry picked from commit 107e1acf5fe79e99a39a57b2aae7045bb5bfcf72) --- base/precompilation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/precompilation.jl b/base/precompilation.jl index 905b931b6b8a2..d0fb0baa0a367 100644 --- a/base/precompilation.jl +++ b/base/precompilation.jl @@ -892,7 +892,7 @@ function _precompilepkgs(pkgs::Vector{String}, flags, cacheflags = config task = @async begin try - loaded = haskey(Base.loaded_modules, pkg) + loaded = warn_loaded && haskey(Base.loaded_modules, pkg) for dep in deps # wait for deps to finish wait(was_processed[(dep,config)]) end From ecd44ffd10eadcc50473ebc4831015838761d3e2 Mon Sep 17 00:00:00 2001 From: JonasIsensee Date: Fri, 18 Jul 2025 22:28:54 +0200 Subject: [PATCH 11/19] Bugfix: Use Base.aligned_sizeof instead of sizeof in Mmap.mmap (#58998) fix #58982 (cherry picked from commit c30199fe17aa24f77530bd64f7762546c15e2941) --- stdlib/Mmap/src/Mmap.jl | 8 ++++---- stdlib/Mmap/test/runtests.jl | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/stdlib/Mmap/src/Mmap.jl b/stdlib/Mmap/src/Mmap.jl index df2f4f1a19991..b3b03509f700b 100644 --- a/stdlib/Mmap/src/Mmap.jl +++ b/stdlib/Mmap/src/Mmap.jl @@ -187,16 +187,16 @@ like HDF5 (which can be used with memory-mapping). """ function mmap(io::IO, ::Type{Array{T,N}}=Vector{UInt8}, - dims::NTuple{N,Integer}=(div(filesize(io)-position(io),sizeof(T)),), + dims::NTuple{N,Integer}=(div(filesize(io)-position(io),Base.aligned_sizeof(T)),), offset::Integer=position(io); grow::Bool=true, shared::Bool=true) where {T,N} # check inputs isopen(io) || throw(ArgumentError("$io must be open to mmap")) isbitstype(T) || throw(ArgumentError("unable to mmap $T; must satisfy isbitstype(T) == true")) - len = sizeof(T) + len = Base.aligned_sizeof(T) for l in dims len, overflow = Base.Checked.mul_with_overflow(promote(len, l)...) - overflow && throw(ArgumentError("requested size prod($((sizeof(T), dims...))) too large, would overflow typeof(size(T)) == $(typeof(len))")) + overflow && throw(ArgumentError("requested size prod($((len, dims...))) too large, would overflow typeof(size(T)) == $(typeof(len))")) end len >= 0 || throw(ArgumentError("requested size must be ≥ 0, got $len")) len == 0 && return Array{T}(undef, ntuple(x->0,Val(N))) @@ -272,7 +272,7 @@ end mmap(file::AbstractString, ::Type{T}=Vector{UInt8}, - dims::NTuple{N,Integer}=(div(filesize(file),sizeof(eltype(T))),), + dims::NTuple{N,Integer}=(div(filesize(file),Base.aligned_sizeof(eltype(T))),), offset::Integer=Int64(0); grow::Bool=true, shared::Bool=true) where {T<:Array,N} = open(io->mmap(io, T, dims, offset; grow=grow, shared=shared), file, isfile(file) ? "r" : "w+")::Array{eltype(T),N} diff --git a/stdlib/Mmap/test/runtests.jl b/stdlib/Mmap/test/runtests.jl index 03e4b48d95f7a..224664e5faaa2 100644 --- a/stdlib/Mmap/test/runtests.jl +++ b/stdlib/Mmap/test/runtests.jl @@ -44,7 +44,7 @@ s = open(file) @test length(@inferred mmap(s, Vector{Int8}, 12, 0; grow=false)) == 12 @test length(@inferred mmap(s, Vector{Int8}, 12, 0; shared=false)) == 12 close(s) -@test_throws ErrorException mmap(file, Vector{Ref}) # must be bit-type +@test_throws ArgumentError mmap(file, Vector{Ref}) # must be bit-type GC.gc(); GC.gc() s = open(f->f,file,"w") @@ -341,6 +341,19 @@ end GC.gc() rm(file) +@testset "test for #58982 - mmap with primitive types" begin + file = tempname() + primitive type PrimType9Bytes 9*8 end + arr = Vector{PrimType9Bytes}(undef, 2) + write(file, arr) + m = mmap(file, Vector{PrimType9Bytes}) + @test length(m) == 2 + @test m[1] == arr[1] + @test m[2] == arr[2] + finalize(m); m = nothing; GC.gc() + rm(file) +end + @testset "Docstrings" begin @test isempty(Docs.undocumented_names(Mmap)) end From 9e77df2965bdfecc9c61e084f34700798541d1c5 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Mon, 28 Jul 2025 20:01:22 -0500 Subject: [PATCH 12/19] Fix memory order typo in "src/julia_atomics.h" (#59120) (cherry picked from commit fde79f5bb5c4835189bfe3215521137176ac3eb8) --- src/julia_atomics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/julia_atomics.h b/src/julia_atomics.h index c094afcc54cd5..d197a7f0dc793 100644 --- a/src/julia_atomics.h +++ b/src/julia_atomics.h @@ -190,7 +190,7 @@ T jl_atomic_exchange_explicit(std::atomic *ptr, S desired, std::memory_order { return std::atomic_exchange_explicit(ptr, desired, order); } -#define jl_atomic_exchange_release(ptr, val) jl_atomic_exchange_explicit(ptr, val, memory_order_reease) +#define jl_atomic_exchange_release(ptr, val) jl_atomic_exchange_explicit(ptr, val, memory_order_release) #define jl_atomic_exchange_relaxed(ptr, val) jl_atomic_exchange_explicit(ptr, val, memory_order_relaxed) extern "C" { #else From 10014c5c8c4256b6158c71a61e7f70fd668b6ed1 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 31 Jul 2025 19:58:09 -0400 Subject: [PATCH 13/19] Clarify and enhance confusing precompile test (#59170) (cherry picked from commit 1f6eff183db0b947632f780b4acc440d9c41a6e2) --- test/precompile.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/precompile.jl b/test/precompile.jl index 5abf917ccd640..ce67d2e56c8a1 100644 --- a/test/precompile.jl +++ b/test/precompile.jl @@ -687,7 +687,10 @@ precompile_test_harness(false) do dir error("the \"break me\" test failed") catch exc isa(exc, ErrorException) || rethrow() - occursin("ERROR: LoadError: break me", exc.msg) && rethrow() + # The LoadError shouldn't be surfaced but is printed to stderr, hence the `@test_warn` capture tests + occursin("LoadError: break me", exc.msg) && rethrow() + # The actual error that is thrown + occursin("Failed to precompile FooBar2", exc.msg) || rethrow() end # Test that trying to eval into closed modules during precompilation is an error From 5225013a8bff7e14a78738ccaa2fcdc9f8b0eb98 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Mon, 25 Aug 2025 08:58:44 -0400 Subject: [PATCH 14/19] [backports-release-1.11] Change Distributed branch from `master` to `release-julia-1.11` (but keep the commit the same) (#59390) This PR will be followed up with a stdlib bump with the Distributed backports. --- stdlib/Distributed.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/Distributed.version b/stdlib/Distributed.version index 02eac7eadf0ad..03073129cff05 100644 --- a/stdlib/Distributed.version +++ b/stdlib/Distributed.version @@ -1,4 +1,4 @@ -DISTRIBUTED_BRANCH = master +DISTRIBUTED_BRANCH = release-julia-1.11 DISTRIBUTED_SHA1 = 6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781 DISTRIBUTED_GIT_URL := https://github.com/JuliaLang/Distributed.jl DISTRIBUTED_TAR_URL = https://api.github.com/repos/JuliaLang/Distributed.jl/tarball/$1 From a5f88ec17664a6f443b9a64f9d4c720f578cf507 Mon Sep 17 00:00:00 2001 From: DilumAluthgeBot <43731525+DilumAluthgeBot@users.noreply.github.com> Date: Mon, 25 Aug 2025 12:18:03 -0400 Subject: [PATCH 15/19] =?UTF-8?q?=F0=9F=A4=96=20[backports-release-1.11]?= =?UTF-8?q?=20Bump=20the=20Distributed=20stdlib=20from=206c7cdb5=20to=20e9?= =?UTF-8?q?b9023=20(#59391)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stdlib: Distributed URL: https://github.com/JuliaLang/Distributed.jl Stdlib branch: release-julia-1.11 Julia branch: backports-release-1.11 Old commit: 6c7cdb5 New commit: e9b9023 Julia version: 1.11.5 Distributed version: 1.11.0(Does not match) Bump invoked by: @DilumAluthge Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: https://github.com/JuliaLang/Distributed.jl/compare/6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781...e9b902372d509cfc11d3c85344acbb9c9e4fa5fe ``` $ git log --oneline 6c7cdb5..e9b9023 e9b9023 Backports for Julia 1.11.x (#141) ``` Co-authored-by: DilumAluthge <5619885+DilumAluthge@users.noreply.github.com> --- .../md5 | 1 - .../sha512 | 1 - .../md5 | 1 - .../sha512 | 1 - .../md5 | 1 + .../sha512 | 1 + stdlib/Distributed.version | 2 +- 7 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/md5 delete mode 100644 deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/sha512 delete mode 100644 deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/md5 delete mode 100644 deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/sha512 create mode 100644 deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/md5 create mode 100644 deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/sha512 diff --git a/deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/md5 b/deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/md5 deleted file mode 100644 index 91dfaf6968e2b..0000000000000 --- a/deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -5c6463034c358a254074e86ab81720b1 diff --git a/deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/sha512 b/deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/sha512 deleted file mode 100644 index 0ad09e2e6bf50..0000000000000 --- a/deps/checksums/Distributed-41c01069533e22a6ce6b794746e4b3aa9f5a25cd.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -bebc472ed89afc8f48eabe0ec0673cf416c5fc3b2f3c51599b388f47e47e6c9905a8a033a3f4b5c38a29be515c43fd70ef44750e7d6f8c6ecd8dc491b3012ac0 diff --git a/deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/md5 b/deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/md5 deleted file mode 100644 index 9904464c82b3b..0000000000000 --- a/deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -390521058a478a131ca49d349c9b9383 diff --git a/deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/sha512 b/deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/sha512 deleted file mode 100644 index a7fbe055c2251..0000000000000 --- a/deps/checksums/Distributed-6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -7f0f414d94739a25b7d713c46887e26cd349329828d42297f44928204b36d15ba9163ad6f670aba72ed9229557bb0f35ab4686429975d1f349fe12b1ba2b189f diff --git a/deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/md5 b/deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/md5 new file mode 100644 index 0000000000000..03069097ba248 --- /dev/null +++ b/deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/md5 @@ -0,0 +1 @@ +cf55027baeae7811676fbfde35bb1b02 diff --git a/deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/sha512 b/deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/sha512 new file mode 100644 index 0000000000000..f5d2c885301c4 --- /dev/null +++ b/deps/checksums/Distributed-e9b902372d509cfc11d3c85344acbb9c9e4fa5fe.tar.gz/sha512 @@ -0,0 +1 @@ +5169f15d3e280632dd96206442622bcae49be6f28896a348ab774f62387640c10ce97d782e937dd6386a6d68592d07b238f4ef4c5e87047b5ae5f370a5aa065f diff --git a/stdlib/Distributed.version b/stdlib/Distributed.version index 03073129cff05..a4cb50a62d208 100644 --- a/stdlib/Distributed.version +++ b/stdlib/Distributed.version @@ -1,4 +1,4 @@ DISTRIBUTED_BRANCH = release-julia-1.11 -DISTRIBUTED_SHA1 = 6c7cdb5860fa5cb9ca191ce9c52a3d25a9ab3781 +DISTRIBUTED_SHA1 = e9b902372d509cfc11d3c85344acbb9c9e4fa5fe DISTRIBUTED_GIT_URL := https://github.com/JuliaLang/Distributed.jl DISTRIBUTED_TAR_URL = https://api.github.com/repos/JuliaLang/Distributed.jl/tarball/$1 From 9aa9ec6e5706f42fb6c7c59682a0bacfd536e566 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Thu, 28 Aug 2025 13:20:07 -0400 Subject: [PATCH 16/19] Revert "Unicode: Force-inline isgraphemebreak! (#58674)" This reverts commit 47ebf952ea2bc46d9d27a0668edff23b0956a35d. --- stdlib/Unicode/test/runtests.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/stdlib/Unicode/test/runtests.jl b/stdlib/Unicode/test/runtests.jl index 2af7015afa249..7fa57508cffbf 100644 --- a/stdlib/Unicode/test/runtests.jl +++ b/stdlib/Unicode/test/runtests.jl @@ -284,8 +284,6 @@ end @test_throws BoundsError graphemes("äöüx", 2:5) @test_throws BoundsError graphemes("äöüx", 5:5) @test_throws ArgumentError graphemes("äöüx", 0:1) - - @test @allocated(length(graphemes("äöüx"))) == 0 end @testset "#3721, #6939 up-to-date character widths" begin From ddcbe4dd84c55dbbe2374b673aad13c340f09b8f Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 31 Aug 2025 10:04:49 -0400 Subject: [PATCH 17/19] [`backports-release-1.11`]: Revert "fix null comparisons for non-standard address spaces (#58837)" (#59445) This reverts commit 3b04664577713059bee663fb3d1cd37080a7ff8e (which backports #58837 to 1.11.x). For more details, see https://github.com/JuliaLang/julia/pull/59336#issuecomment-3239568360 and https://github.com/JuliaLang/julia/pull/59336#issuecomment-3239575723. Targets `backports-release-1.11` (#59336). --- src/cgutils.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 180c8fdfb0021..405103076bd75 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -1395,17 +1395,10 @@ static void undef_var_error_ifnot(jl_codectx_t &ctx, Value *ok, jl_sym_t *name, ctx.builder.SetInsertPoint(ifok); } -// ctx.builder.CreateIsNotNull(v) lowers incorrectly in non-standard -// address spaces where null is not zero -// TODO: adapt to https://github.com/llvm/llvm-project/pull/131557 once merged static Value *null_pointer_cmp(jl_codectx_t &ctx, Value *v) { ++EmittedNullchecks; - Type *T = v->getType(); - return ctx.builder.CreateICmpNE( - v, - ctx.builder.CreateAddrSpaceCast( - Constant::getNullValue(ctx.builder.getPtrTy(0)), T)); + return ctx.builder.CreateIsNotNull(v); } From fb73efef0f22174c548dbd346ca2dda0962fbef4 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Mon, 1 Sep 2025 01:29:37 -0400 Subject: [PATCH 18/19] ("remove a testset from MMAP that might cause CI to now fail on Windows") (#59452) --- stdlib/Mmap/test/runtests.jl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/stdlib/Mmap/test/runtests.jl b/stdlib/Mmap/test/runtests.jl index 224664e5faaa2..0c34c49d400a7 100644 --- a/stdlib/Mmap/test/runtests.jl +++ b/stdlib/Mmap/test/runtests.jl @@ -341,18 +341,18 @@ end GC.gc() rm(file) -@testset "test for #58982 - mmap with primitive types" begin - file = tempname() - primitive type PrimType9Bytes 9*8 end - arr = Vector{PrimType9Bytes}(undef, 2) - write(file, arr) - m = mmap(file, Vector{PrimType9Bytes}) - @test length(m) == 2 - @test m[1] == arr[1] - @test m[2] == arr[2] - finalize(m); m = nothing; GC.gc() - rm(file) -end +# test for #58982 - mmap with primitive types +file = tempname() +primitive type PrimType9Bytes 9*8 end +arr = Vector{PrimType9Bytes}(undef, 2) +write(file, arr) +m = mmap(file, Vector{PrimType9Bytes}) +@test length(m) == 2 +@test m[1] == arr[1] +@test m[2] == arr[2] +finalize(m); m = nothing; GC.gc() +rm(file) + @testset "Docstrings" begin @test isempty(Docs.undocumented_names(Mmap)) From b04078de60e1bad3cba7ca4659694946c0d2a9d7 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Mon, 1 Sep 2025 18:04:23 -0300 Subject: [PATCH 19/19] Remove failing test --- test/llvmpasses/late-lower-gc.ll | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/llvmpasses/late-lower-gc.ll b/test/llvmpasses/late-lower-gc.ll index 8f7b2523b6996..62122b2ad4ec9 100644 --- a/test/llvmpasses/late-lower-gc.ll +++ b/test/llvmpasses/late-lower-gc.ll @@ -226,20 +226,6 @@ define void @decayar([2 x {} addrspace(10)* addrspace(11)*] %ar) { ; OPAQUE: %r = call i32 @callee_root(ptr addrspace(10) %l0, ptr addrspace(10) %l1) ; OPAQUE: call void @julia.pop_gc_frame(ptr %gcframe) -define swiftcc ptr addrspace(10) @insert_element(ptr swiftself %0) { -; CHECK-LABEL: @insert_element - %2 = alloca [10 x i64], i32 1, align 8 -; CHECK: %gcframe = call ptr @julia.new_gc_frame(i32 10) -; CHECK: [[gc_slot_addr_:%.*]] = call ptr @julia.get_gc_frame_slot(ptr %gcframe, i32 0) -; CHECK: call void @julia.push_gc_frame(ptr %gcframe, i32 10) - call void null(ptr sret([2 x [5 x ptr addrspace(10)]]) %2, ptr null, ptr addrspace(11) null, ptr null) - %4 = insertelement <4 x ptr> zeroinitializer, ptr %2, i32 0 -; CHECK: [[gc_slot_addr_:%.*]] = insertelement <4 x ptr> zeroinitializer, ptr [[gc_slot_addr_:%.*]], i32 0 -; CHECK: call void @julia.pop_gc_frame(ptr %gcframe) - ret ptr addrspace(10) null -} - - !0 = !{i64 0, i64 23} !1 = !{!1} !2 = !{!7} ; scope list