Skip to content

Conversation

@KristofferC
Copy link
Member

@KristofferC KristofferC commented Oct 21, 2025

KristofferC and others added 6 commits October 21, 2025 09:48
…59878)

Noticed during bug hunting of

ericphanson/LicenseCheck.jl#11 (comment)
and may cause performance degradation for interpreter-executed try
blocks or scope entry.

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
(cherry picked from commit c1353ac)
This prevents a bunch of invalidations, specifically these ones in Julia
1.12 with UnsafePointers.jl (CC @cjdoris):
```julia
 inserting convert(P::Type{<:Ptr}, p::UnsafePointers.UnsafePtr) @ UnsafePointers ~/git/UnsafePointers.jl/src/UnsafePointers.jl:66 invalidated:
   mt_backedges:  1: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_npointers(::Type{T} where T<:(NamedTuple{names, T} where {T<:Tuple, names})) (4 children)
                  2: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_npointers(::Type{T} where T<:AbstractString) (4 children)
                  3: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_npointers(::Type{T} where T<:Tuple{Symbol, Any}) (4 children)
                  4: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_npointers(::Type{T} where T<:(NamedTuple{(:message, :position, :hint), _A} where _A)) (4 children)
                  5: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_npointers(::Type{T} where T<:(SubString{_A} where _A)) (4 children)
                  6: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_alignment(::Type{T} where T<:(NamedTuple{(:message, :position, :hint), _A} where _A)) (15 children)
                  7: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_alignment(::Type{T} where T<:(SubString{_A} where _A)) (19 children)
                  8: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_alignment(::Type{T} where T<:Tuple{Any, Symbol, Symbol}) (21 children)
                  9: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_alignment(::Type{T} where T<:Tuple{Symbol, Any}) (23 children)
                 10: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_alignment(::Type{T} where T<:AbstractString) (52 children)
                 11: signature Tuple{typeof(convert), Type{Ptr{Base.DataTypeLayout}}, Any} triggered MethodInstance for Base.datatype_alignment(::Type{T} where T<:(NamedTuple{names, T} where {T<:Tuple, names})) (1739 children)
```

Using Cthulhu to look at the last invalidation with 1739 children showed
this:
```julia
datatype_alignment(dt::DataType) @ Base ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/base/runtime_internals.jl:544
544 function datatype_alignment(dt::Type{T} where T<:(NamedTuple{names, T} where {T<:Tuple, names})::DataType)::Any
545     @_foldable_meta
546     (dt::Type{T} where T<:(NamedTuple{names, T} where {T<:Tuple, names}).layout::Any == C_NULL::Core.Const(Ptr{Nothing}(0x0000000000000000)))::Any && throw(UndefRefError()::Core.Const(UndefRefError()))
547     alignment::Any = unsafe_load(convert(Ptr{DataTypeLayout}::Type{Ptr{Base.DataTypeLayout}}, dt::Type{T} where T<:(NamedTuple{names, T} where {T<:Tuple, names}).layout::Any)::Any)::Any.alignment::Any
548     return Int::Type{Int64}(alignment::Any)::Any
549 end
```

The `.layout` field was getting inferred as `Any` which caused that
method to be invalidated when UnsafePointers.jl defined a new
`convert()` method.

Would it be possible to backport this to 1.12? UnsafePointers is a
dependency of PythonCall so it's quite widely used.

---------

Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
(cherry picked from commit 90f4289)
This change is not necessary for `NativeInterpreter` at all, but is
particularly useful for JET. For error reporting, which is the purpose
of `JETAnalyzer`, it is desirable to present error causes in a
user-understandable form even when concrete evaluation presents errors.
This requires analysis using regular abstract interpretation (constant
propagation) in general. However, to reduce false positives, the
precision that concrete evaluation brings is very important, and
completely disabling concrete evaluation is not desirable either.
Currently, `JETAnalyzer` aims to avoid this tradeoff by limiting
concrete evaluation to only some functions, but this approach does not
scale and occasionally causes problems like #59884.

This commit enables ad-hoc cancellation of concrete evaluation based on
the result of `concrete_eval_call`, allowing `JETAnalyzer` to fallback
to abstract interpretation only when concrete evaluation causes errors,
fundamentally avoiding such problems.

(cherry picked from commit c6091de)
@KristofferC KristofferC added the release Release management and versioning. label Oct 21, 2025
@KristofferC KristofferC changed the title set VERSION to 1.12.1 (#59871) Backports for 1.12.2 Oct 21, 2025
…iew` (#59915)

When packages using non-Base compilers call `Base._which`, a method
error occurs due to module context mismatch. Like other reflection
functions, the module context of `mt::Compiler.MethodTableView` needs to
be properly determined.
@ViralBShah
Copy link
Member

Hopefully the linalg bump can make it in: #59927

#59927)

Stdlib: LinearAlgebra
URL: https://github.com/JuliaLang/LinearAlgebra.jl.git
Stdlib branch: release-1.12
Julia branch: backports-release-1.12
Old commit: 24f5e21
New commit: 5567504
Julia version: 1.12.1
LinearAlgebra version: 1.12.0(Does not match)
Bump invoked by: @ViralBShah
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/LinearAlgebra.jl@24f5e21...5567504

```
$ git log --oneline 24f5e21..5567504
5567504 Backports to v1.12 (#1472)
a2a4981 Overload array constructors for BunchKaufman (#1461) (#1466)
1ebc0cb Generic fallback for `fillstored!` (#1389)
```

Co-authored-by: ViralBShah <744411+ViralBShah@users.noreply.github.com>
@KSepetanc
Copy link

KSepetanc commented Oct 23, 2025

PR #59736 is marked here as needs manual backport, but has been marked as backported in 1.12.1. Why?

@KristofferC
Copy link
Member Author

I guess I forgot to remove the label

…all_name` (#59921)

This prevents invalidations of `isready()` from loading Distributed on
1.12:
```julia
 inserting isready(pool::Distributed.WorkerPool) @ Distributed ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/stdlib/v1.12/Distributed/src/workerpool.jl:168 invalidated:
   mt_backedges: 1: signature Tuple{typeof(isready), Any} triggered MethodInstance for (::Compiler.var"#evalargs#abstract_eval_nonlinearized_foreigncall_name##0"{Expr, Compiler.StatementState, Compiler.Future{Compiler.CallMeta}, Vector{Any}, Int64})(::Compiler.AbstractInterpreter, ::Compiler.InferenceState) (0 children)
                 2: signature Tuple{typeof(isready), Any} triggered MethodInstance for (::Compiler.var"#evalargs#abstract_eval_nonlinearized_foreigncall_name##0"{Expr, Compiler.StatementState, Compiler.Future{Compiler.CallMeta}, Vector{Any}, Int64})(::Compiler.NativeInterpreter, ::Compiler.InferenceState) (0 children)
                 3: signature Tuple{typeof(isready), Any} triggered MethodInstance for (::Compiler.var"#evalargs#abstract_eval_nonlinearized_foreigncall_name##0"{Expr, Compiler.StatementState, Compiler.Future{Compiler.CallMeta}, Vector{Any}, Int64})(::Compiler.AbstractInterpreter, ::Compiler.InferenceState) (249 children)
```

I think ideally it wouldn't use a closure at all, but I'm not familiar
enough with the code to refactor it that much. I'm making the PR against
the `release-1.12` branch because this function is deleted entirely on
master by #59165.
@KristofferC
Copy link
Member Author

Please cherry pick with -x when pushing them here.

@vtjnash
Copy link
Member

vtjnash commented Oct 24, 2025

I don't know who that is directed at, but note that #59921 is not a backport, but a v1.12-only bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Release management and versioning.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants