Skip to content

Commit 95639de

Browse files
gbaraldiDilumAluthgexal-0topolarityvtjnash
authored
Backports for Julia 1.11.8 (#59521)
Backported PRs: - [x] #57523 <!-- Remove usages of weak symbols --> - [x] #58127 <!-- [DOC] Update installation docs: /downloads/ => /install/ --> - [x] #58202 <!-- [release-1.11] malloc: use jl_get_current_task to fix null check --> - [x] #58554 <!-- remove workaround for controlling terminal behavior in repl_cmd --> - [x] #58584 <!-- Make `Ptr` values static-show w/ type-information --> - [x] #59062 <!-- remove a testset from MMAP that might cause CI to now fail on Windows --> - [x] #59300 <!-- Update the developer docs to reflect the use of JuliaSyntax.jl --> - [x] #57604 <!-- `@nospecialize` for `string_index_err` --> - [x] #59329 <!-- aotcompile: destroy LLVM context after serializing combined module --> - [x] #59418 <!-- Fix startup when history file is bad --> - [x] #56890 <!-- Enable getting non-boxed LLVM type from Julia Type --> - [x] #59559 <!-- codegen: mark write barrier field load as volatile --> - [x] #59572 <!-- Only apply Base.Sort.SubArrayOptimization when iszero(v.offset1) --> Need manual backport: - [ ] #56329 <!-- loading: clean up more concurrency issues --> - [ ] #56956 <!-- Add "mea culpa" to foreign module assignment error. --> - [ ] #57035 <!-- linux: workaround to avoid deadlock inside dl_iterate_phdr in glibc --> - [ ] #57089 <!-- Block thread from receiving profile signal with stackwalk lock --> - [ ] #57249 <!-- restore non-freebsd-unix fix for profiling --> - [ ] #58011 <!-- Remove try-finally scope from `@time_imports` `@trace_compile` `@trace_dispatch` --> - [ ] #58062 <!-- remove unnecessary edge from `exp_impl` to `pow` --> - [ ] #58157 <!-- add showing a string to REPL precompile workload --> - [ ] #58209 <!-- Specialize `one` for the `SizedArray` test helper --> - [ ] #58356 <!-- codegen: remove readonly from abstract type calling convention --> - [ ] #58415 <!-- [REPL] more reliable extension loading --> - [ ] #58510 <!-- Don't filter `Core` methods from newly-inferred list --> - [ ] #58110 <!-- relax dispatch for the `IteratorSize` method for `Generator` --> - [ ] #58965 <!-- Fix `hygienic-scope`s in inner macro expansions --> - [ ] #58971 <!-- Fix alignment of failed precompile jobs on CI --> - [ ] #59066 <!-- build: Also pass -fno-strict-aliasing for C++ --> - [ ] #59428 <!-- Correctly set the variant bits of uuid1 --> Contains multiple commits, manual intervention needed: - [ ] #55877 <!-- fix FileWatching designs and add workaround for a stat bug on Apple --> - [ ] #56755 <!-- docs: fix scope type of a `struct` to hard --> - [ ] #57809 <!-- Fix fptrunc Float64 -> Float16 rounding through Float32 --> - [ ] #57398 <!-- Make remaining float intrinsics require float arguments --> - [ ] #56351 <!-- Fix `--project=@script` when outside script directory --> - [ ] #57129 <!-- clarify that time_ns is monotonic --> - [ ] #58134 <!-- Note annotated string API is experimental in Julia 1.11 in HISTORY.md --> - [ ] #58401 <!-- check that hashing of types does not foreigncall (`jl_type_hash` is concrete evaluated) --> - [ ] #58435 <!-- Fix layout flags for types that have oddly sized primitive type fields --> - [ ] #58483 <!-- Fix tbaa usage when storing into heap allocated immutable structs --> - [ ] #58512 <!-- Make more types jl_static_show readably --> - [ ] #58012 <!-- Re-enable tab completion of kwargs for large method tables --> - [ ] #58683 <!-- Add 0 predecessor to entry basic block and handle it in inlining --> - [ ] #59112 <!-- Add builtin function name to add methods error --> - [ ] #56823 <!-- Make version of opaque closure constructor in world --> - [ ] #59467 <!-- `CoreLogging`: prevent some `Annotated*`-related instability --> Non-merged PRs with backport label: - [ ] #59450 <!-- Propagate Addrspaces: fix lift of memset --> - [ ] #58848 <!-- Set array size only when safe to do so --> - [ ] #55958 <!-- also redirect JL_STDERR etc. when redirecting to devnull --> - [ ] #55956 <!-- Make threadcall gc safe --> - [ ] #55534 <!-- Set stdlib sources as read-only during installation --> - [ ] #55499 <!-- propagate the terminal's `displaysize` to the `IOContext` used by the REPL --> - [ ] #55458 <!-- Allow for generically extracting unannotated string --> - [ ] #55457 <!-- Make AnnotateChar equality consider annotations --> - [ ] #55220 <!-- `isfile_casesensitive` fixes on Windows --> - [ ] #53957 <!-- tweak how filtering is done for what packages should be precompiled --> - [ ] #51479 <!-- prevent code loading from lookin in the versioned environment when building Julia --> - [ ] #50813 <!-- More doctests for Sockets and capitalization fix --> - [ ] #50157 <!-- improve docs for `@inbounds` and `Base.@propagate_inbounds` --> --------- Co-authored-by: Dilum Aluthge <[email protected]> Co-authored-by: Sam Schweigel <[email protected]> Co-authored-by: Cody Tapscott <[email protected]> Co-authored-by: Jameson Nash <[email protected]> Co-authored-by: Adam Wheeler <[email protected]> Co-authored-by: Neven Sajko <[email protected]> Co-authored-by: Shuhei Kadowaki <[email protected]> Co-authored-by: Ian Butterworth <[email protected]> Co-authored-by: William Moses <[email protected]> Co-authored-by: Valentin Churavy <[email protected]> Co-authored-by: Lilith Orion Hafner <[email protected]>
1 parent f2b3dbd commit 95639de

37 files changed

+735
-581
lines changed

.buildkite-external-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
main
1+
release-julia-1.11

base/client.jl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ stackframe_lineinfo_color() = repl_color("JULIA_STACKFRAME_LINEINFO_COLOR", :bol
3232
stackframe_function_color() = repl_color("JULIA_STACKFRAME_FUNCTION_COLOR", :bold)
3333

3434
function repl_cmd(cmd, out)
35-
shell = shell_split(get(ENV, "JULIA_SHELL", get(ENV, "SHELL", "/bin/sh")))
36-
shell_name = Base.basename(shell[1])
37-
3835
# Immediately expand all arguments, so that typing e.g. ~/bin/foo works.
3936
cmd.exec .= expanduser.(cmd.exec)
4037

@@ -64,19 +61,15 @@ function repl_cmd(cmd, out)
6461
cd(dir)
6562
println(out, pwd())
6663
else
67-
@static if !Sys.iswindows()
68-
if shell_name == "fish"
69-
shell_escape_cmd = "begin; $(shell_escape_posixly(cmd)); and true; end"
70-
else
71-
shell_escape_cmd = "($(shell_escape_posixly(cmd))) && true"
72-
end
64+
if !Sys.iswindows()
65+
shell = shell_split(get(ENV, "JULIA_SHELL", get(ENV, "SHELL", "/bin/sh")))
66+
shell_escape_cmd = shell_escape_posixly(cmd)
7367
cmd = `$shell -c $shell_escape_cmd`
7468
end
7569
try
7670
run(ignorestatus(cmd))
7771
catch
78-
# Windows doesn't shell out right now (complex issue), so Julia tries to run the program itself
79-
# Julia throws an exception if it can't find the program, but the stack trace isn't useful
72+
# Julia throws an exception if it can't find the cmd (which may be the shell itself), but the stack trace isn't useful
8073
lasterr = current_exceptions()
8174
lasterr = ExceptionStack([(exception = e[1], backtrace = [] ) for e in lasterr])
8275
invokelatest(display_error, lasterr)

base/loading.jl

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,7 +2640,48 @@ function _require_from_serialized(uuidkey::PkgId, path::String, ocachepath::Unio
26402640
end
26412641

26422642
# load a serialized file directly from append_bundled_depot_path for uuidkey without stalechecks
2643-
function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=nothing)
2643+
"""
2644+
require_stdlib(package_uuidkey::PkgId, [ext::String, from::Module])
2645+
2646+
!!! warning "May load duplicate copies of stdlib packages."
2647+
2648+
This requires that all stdlib packages loaded are compatible with having concurrent
2649+
copies of themselves loaded into memory. It also places additional restrictions on
2650+
the kinds of type-piracy that are allowed in stdlibs, since type-piracy can cause the
2651+
dispatch table to become visibly "torn" across multiple different packages.
2652+
2653+
The specific requirements are:
2654+
2655+
The import side (caller of `require_stdlib`) must not leak any stdlib types, esp.
2656+
to any context that may have a conflicting copy of the stdlib(s) (or vice-versa).
2657+
- e.g., if an output is forwarded to user code, it must contain only Base types.
2658+
- e.g., if an output contains types from the stdlib, it must be consumed "internally"
2659+
before reaching user code.
2660+
2661+
The imported code (loaded stdlibs) must be very careful about type piracy:
2662+
- It must not access any global state that may differ between stdlib copies in
2663+
type-pirated methods.
2664+
- It must not return any stdlib types from any type-pirated public methods (since
2665+
a loaded duplicate would overwrite the Base method again, returning different
2666+
types that don't correspond to the user-accessible copy of the stdlib).
2667+
- It must not pass / discriminate stdlib types in type-pirated methods, except
2668+
indirectly via methods defined in Base and implemented (w/o type-piracy) in
2669+
all copies of the stdlib over their respective types.
2670+
2671+
The idea behind the above restrictions is that any type-pirated methods in the stdlib
2672+
must return a result that is simultaneously correct for all of the stdlib's loaded
2673+
copies, including accounting for global state differences and split type identities.
2674+
2675+
Furthermore, any imported code must not leak any stdlib types to globals and containers
2676+
(e.g. Vectors and mutable structs) in upstream Modules, since this will also lead to
2677+
type-confusion when the type is later pulled out in user / stdlib code.
2678+
2679+
For examples of issues like the above, see:
2680+
[1] https://github.com/JuliaLang/Pkg.jl/issues/4017#issuecomment-2377589989
2681+
[2] https://github.com/JuliaLang/StyledStrings.jl/issues/91#issuecomment-2379602914
2682+
"""
2683+
require_stdlib(package_uuidkey::PkgId) = require_stdlib(package_uuidkey, nothing, Base)
2684+
function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}, from::Module)
26442685
if generating_output(#=incremental=#true)
26452686
# Otherwise this would lead to awkward dependency issues by loading a package that isn't in the Project/Manifest
26462687
error("This interactive function requires a stdlib to be loaded, and package code should instead use it directly from that stdlib.")
@@ -2652,35 +2693,33 @@ function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=noth
26522693
if newm isa Module
26532694
return newm
26542695
end
2655-
# first since this is a stdlib, try to look there directly first
26562696
env = Sys.STDLIB
2657-
#sourcepath = ""
2658-
if ext === nothing
2659-
sourcepath = normpath(env, this_uuidkey.name, "src", this_uuidkey.name * ".jl")
2660-
else
2661-
sourcepath = find_ext_path(normpath(joinpath(env, package_uuidkey.name)), ext)
2662-
end
2663-
#mbypath = manifest_uuid_path(env, this_uuidkey)
2664-
#if mbypath isa String && isfile_casesensitive(mbypath)
2665-
# sourcepath = mbypath
2666-
#else
2667-
# # if the user deleted the stdlib folder, we next try using their environment
2668-
# sourcepath = locate_package_env(this_uuidkey)
2669-
# if sourcepath !== nothing
2670-
# sourcepath, env = sourcepath
2671-
# end
2672-
#end
2673-
#if sourcepath === nothing
2674-
# throw(ArgumentError("""
2675-
# Package $(repr("text/plain", this_uuidkey)) is required but does not seem to be installed.
2676-
# """))
2677-
#end
2678-
set_pkgorigin_version_path(this_uuidkey, sourcepath)
2679-
depot_path = append_bundled_depot_path!(empty(DEPOT_PATH))
2680-
newm = start_loading(this_uuidkey, UInt128(0), true)
2681-
newm === nothing || return newm
26822697
try
2683-
newm = _require_search_from_serialized(this_uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
2698+
depot_path = append_bundled_depot_path!(empty(DEPOT_PATH))
2699+
from_stdlib = true # set to false if `from` is a normal package so we do not want the internal loader for the extension either
2700+
if ext isa String
2701+
from_uuid = PkgId(from)
2702+
from_m = get(loaded_modules, from_uuid, nothing)
2703+
if from_m === from
2704+
# if from_uuid is either nothing or points to something else, assume we should use require_stdlib
2705+
# otherwise check cachepath for from to see if it looks like it is from depot_path, since try_build_ids
2706+
cachepath = get(PkgOrigin, pkgorigins, from_uuid).cachepath
2707+
entrypath, entryfile = cache_file_entry(from_uuid)
2708+
from_stdlib = any(x -> startswith(entrypath, x), depot_path)
2709+
end
2710+
end
2711+
if from_stdlib
2712+
# first since this is a stdlib, try to look there directly first
2713+
if ext === nothing
2714+
sourcepath = normpath(env, this_uuidkey.name, "src", this_uuidkey.name * ".jl")
2715+
else
2716+
sourcepath = find_ext_path(normpath(joinpath(env, package_uuidkey.name)), ext)
2717+
end
2718+
set_pkgorigin_version_path(this_uuidkey, sourcepath)
2719+
newm = start_loading(this_uuidkey, UInt128(0), true)
2720+
newm === nothing || return newm
2721+
newm = _require_search_from_serialized(this_uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
2722+
end
26842723
finally
26852724
end_loading(this_uuidkey, newm)
26862725
end
@@ -2690,10 +2729,12 @@ function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=noth
26902729
run_package_callbacks(this_uuidkey)
26912730
else
26922731
# if the user deleted their bundled depot, next try to load it completely normally
2732+
# if it is an extension, we first need to indicate where to find its parant via EXT_PRIMED
2733+
ext isa String && (EXT_PRIMED[this_uuidkey] = PkgId[package_uuidkey])
26932734
newm = _require_prelocked(this_uuidkey)
26942735
end
26952736
return newm
2696-
end
2737+
end # release lock
26972738
end
26982739

26992740

base/sort.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,15 @@ function _sort!(v::UnwrappableSubArray, a::SubArrayOptimization, o::Ordering, kw
556556
@getkw lo hi
557557
# @assert v.stride1 == 1
558558
parent = v.parent
559-
if parent isa Array && !(parent isa Vector) && hi - lo < 100
559+
if parent isa Array && !(parent isa Vector) && hi - lo < 100 || !iszero(v.offset1)
560560
# vec(::Array{T, ≠1}) allocates and is therefore somewhat expensive.
561561
# We don't want that for small inputs.
562+
563+
# Additionally, if offset1 is non-zero, then this optimization is incompatible with
564+
# algorithms that track absolute first and last indices (e.g. ScratchQuickSort)
562565
_sort!(v, a.next, o, kw)
563566
else
564-
_sort!(vec(parent), a.next, o, (;kw..., lo = lo + v.offset1, hi = hi + v.offset1))
567+
_sort!(vec(parent), a.next, o, kw)
565568
end
566569
end
567570

base/strings/string.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ An error occurred when trying to access `str` at index `i` that is not valid.
77
"""
88
struct StringIndexError <: Exception
99
string::AbstractString
10-
index::Integer
10+
index::Int
1111
end
12-
@noinline string_index_err(s::AbstractString, i::Integer) =
12+
@noinline string_index_err((@nospecialize s::AbstractString), i::Integer) =
1313
throw(StringIndexError(s, Int(i)))
1414
function Base.showerror(io::IO, exc::StringIndexError)
1515
s = exc.string

0 commit comments

Comments
 (0)