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 release 1.12 #57536

Open
wants to merge 27 commits into
base: release-1.12
Choose a base branch
from
Open

Backports release 1.12 #57536

wants to merge 27 commits into from

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Feb 26, 2025

Backported PRs:

Non-merged PRs with backport label:

vtjnash and others added 4 commits February 26, 2025 08:45
Fixes the double accounting of the union byte array in
`Base.summarysize` as described in #57506.

If this is the correct fix, can it be backported to 1.11?

Fix #57506

(cherry picked from commit 7b7ba33)
…ional` (#55853)

Relying on `ScopedValues`, set `BigFloat` precision without mutating the
global default, while constructing `Rational` from `AbstractIrrational`.

Also helps avoid reading the global defaults for the precision and
rounding mode, together with #56095.

What does this fix:
* in the case of the `Irrational` constants defined in `MathConstants`:
relevant methods have `@assume_effects :foldable` applied, which
includes `:effect_free`, which requires that no globals be mutated
(followup on #55886)
* in the case of `AbstractIrrational` values in general, this PR
prevents data races on the global `BigFloat` precision

(cherry picked from commit 2a89f71)
@KristofferC KristofferC added the release Release management and versioning. label Feb 26, 2025
vtjnash and others added 23 commits March 3, 2025 13:59
Reimplement all of the trim verification support in Julia as a compiler
analysis pass. Move all this verification code into the Compiler julia
code, where we have much better utilities for pretty printing and better
observability for analysis.

(cherry picked from commit 1045bd8)
Recompute some O(n) things a bit less on every statement. Fix an assert
that ensured LimitedAccuracy does not accidentally get preserved when it
should have been deleted: the (local) cache should not contain things
that are marked as dead (RIP), as that was leading to much code not
getting cached when it logically should have. Simplify the computation
of frame_parent when the cycle_parent isn't needed.

(cherry picked from commit 0366a2a)
- disable load path setup
- remove upstreamed change to utf8proc_map
- fix warning for accessing mod.main in the wrong world
- remove binding backedges when trimming

(cherry picked from commit d77c24f)
This updates the pin to point to main rather than a PR again, and also
includes the commit:

```
b7a1c63 * Guard against assumptions that children exist
```

Fixes #57402

(cherry picked from commit 61de3a4)
This change removes an inconsistency between `>:` and `<:`. We were
parsing `where {A>:B>:C}` forms, but not recognizing them in lowering.

Before:
```
julia> Vector{T} where Int<:T<:Number
Vector{T} where Int64<:T<:Number

julia> Vector{T} where Number>:T>:Int
ERROR: syntax: invalid bounds in "where" around REPL[14]:1
```

After:
```
julia> Vector{T} where Number>:T>:Int
Vector{T} where Int64<:T<:Number
```

(cherry picked from commit 2e57730)
…57558)

Somebody may replace the type with an int. Fixes #57515.

(cherry picked from commit bfe9c2f)
This restores 1.11 behavior. However, I find this function a bit
problematic, since it is asking whether the binding is `constant` in a
particular sense, but not whether it is `const` (in the sense of having
been declared with the keyword or equivalent), so the shortening is
confusing. However, we don't need to address that now. Fixes #57475.

(cherry picked from commit 1ff98a5)
We have historically allowed the following without warning or error:

```
const x = 1
x = 1
```

As well as
```
const x = 1
x = 2
```
with a UB warning.

In 1.12, we made the second case error, as part of the general binding
partition changes, but did not touch the first case, because it did not
have the warning.

I think this made a reasonable amount of sense, because we essentially
treated constants as special kinds of mutable globals (to which
assignment happened to be UB).

However, in the 1.12+ design, constants and globals are quite sepearate
beasts, and I think it makes sense to extend the error to the egal case
also, even if it is technically more breaking.

In fact, I already thought that's what I did when I implemented the new
effect model for global assignment, causing #57566. I can't think of a
legitimate reason to keep this special case. For those who want to do
binding replacement, the `const` keyword is mandatory, so the assignment
is now literally always a semantic no-op or an error.

Fixes #57566.

(cherry picked from commit 8f00a51)
This is my attempt to resolve #53000.

```
julia> solve
ERROR: UndefVarError: `solve` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name also exists in CommonSolve.
    - Also exported by SciMLBase.
    - Also exported by DiffEqBase.
    - Also exported by JumpProcesses.
    - Also exported by LinearSolve.
    - Also exported by BracketingNonlinearSolve (loaded but not imported in Main).
    - Also exported by SimpleNonlinearSolve.
    - Also exported by NonlinearSolve.
    - Also exported by OrdinaryDiffEqLowStorageRK (loaded but not imported in Main).
    - Also exported by OrdinaryDiffEqSSPRK (loaded but not imported in Main).
    - Also exported by OrdinaryDiffEqVerner (loaded but not imported in Main).
    - Also exported by OrdinaryDiffEqBDF (loaded but not imported in Main).
    - Also exported by OrdinaryDiffEqTsit5 (loaded but not imported in Main).
    - Also exported by OrdinaryDiffEqRosenbrock (loaded but not imported in Main).
    - Also exported by OrdinaryDiffEqDefault (loaded but not imported in Main).
    - Also exported by Sundials.
```

I would have beefed up the test case, but can't follow how it works.

---------

Co-authored-by: Alex Arslan <ararslan@comcast.net>
Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
(cherry picked from commit 5f13cd2)
These were supposed to be removed in Julia 1.8 apparently (#40730)

(cherry picked from commit 2dd4cdf)
These were the intended semantics of #57311 (and matches what it used to
do in 1.11). Note however that this differs from the body-ful form,
which now always tries to extend. Fixes #57546.

Note that this implementation is slightly inefficient since it goes
through a binding replacement.
However, there's a change coming down the line which optimizes these
replacements.
I do think it should eventually be refactored to just create the binding
directly, but that's a little bit
of a larger change.

(cherry picked from commit 7fa0c13)
…gler (#57579)

In the line of C code:

```C
const int64_t timeout = jl_options.timeout_for_safepoint_straggler_s * 1000000000;
```

`jl_options.timeout_for_safepoint_straggler_s` is an `int16_t` and
`1000000000` is an `int32_t`.

The result of `jl_options.timeout_for_safepoint_straggler_s *
1000000000` will be an `int32_t` which may not be large enough to hold
the value of `jl_options.timeout_for_safepoint_straggler_s` after
converting to nanoseconds, leading to overflow.

(cherry picked from commit 9cafd35)
…constructor (#57599)

Avoiding the converting `setindex!` should hopefully diminish
unwarranted invalidation of user code.

(cherry picked from commit 1e03ed6)
The `_apply_pure` function only has one user, and that user is unsound
anyways and should not be used, so replace that with equivalent
`_call_in_world_total` call and remove unnecessary definitions.

The awkward distinction between `invokelatest` and `_call_latest` has
not been relevant (and indeed causes performance issues) since kwfunc
was introduced in #47157.

(cherry picked from commit 671c6a1)
)

The type assertions are valid according to the doc strings of these
functions in the case of `AbstractString`.

Should prevent some invalidation on loading user code.

Fixes #57605

(cherry picked from commit 6c9c336)
…s` (#57607)

The type assertions are valid according to the doc strings of these two
functions in the case of `AbstractString`.

Should prevent some invalidation on loading user code.

Fixes #57606

(cherry picked from commit c4eeabf)
* Follows up on/partially reverts #55634
* Reopens #53504, perhaps it's OK to require some types to implement
their own `^` for good performance
* Fixes #57390, a regression

(cherry picked from commit a984a21)
---------

Co-authored-by: Kristoffer <kcarlsson89@gmail.com>
Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com>
(cherry picked from commit 0dd78f7)
This repeats the exercise in #57405. This is required for correctness,
because the ->deprecated flag also affects `using` resolution (since it
makes the tagged binding weaker for `using` purposes). That said, in
general our `->deprecated` semantics have been somewhat underspecified
with lots of `XXX` comments in the surrounding code. This tries to
define the semantics to give a depwarn on *access* (read or write) when:

1. Either the binding itself is deprecated; or
2. The implicit imports pass through a deprecated binding.

However, we do not give depwarns on access to bindings that were
explicitly imported (although we do give those warnings on the import) -
the reasoning being that it's the import that needs to be adjusted not
the access.

Additionally, this PR moves into the direction of making the depwarn a
semantic part of the global access, by adjusting codegen and inference
appropriately.

(cherry picked from commit 1a3cbb1)
When inference and codegen queries the partitions of a binding, they
often only care about a subset of the information in the partition. At
the moment, we always truncate world ranges to the most precise
partition that contains the relevant query. However, we can instead
expand the world range to cover all partitions that are equivalent for
the given query. To give a concrete example, both inference and codegen
never care about the exported flag in a binding partition, so we should
not unnecessarily truncate a world range just because an export was
introduced.

Further, this commit lays the ground work to stop invalidating code for
these same kinds of transitions, although the actual logic to do that
will come in a separate PR.

(cherry picked from commit a5157c0)
This renames the partition flags to start with PARTITION_ and turns the
Binding flags into a bitfield that can be accessed atomically in
preparation for adding further flags.

(cherry picked from commit a802faf)
Our implicit edge tracking for bindings does not explicitly store any
edges for bindings in the *current* module. The idea behind this is that
this is a good time-space tradeoff for validation, because substantially
all binding references in a module will be to its defining module, while
the total number of methods within a module is limited and substantially
smaller than the total number of methods in the entire system.

However, we have an issue where the code that stores these edges and the
invalidation code disagree on which module is the *current* one. The
edge storing code was using the module in which the method was defined,
while the invalidation code was using the one in which the MethodTable
is defined. With these being misaligned, we can miss necessary
invalidations.

Both options are in principle possible, but I think the former is
better, because the module in which the method is defined is also the
module that we are likely to have a lot of references to (since they get
referenced implicitly by just writing symbols in the code).

However, this presents a problem: We don't actually have a way to
iterate all the methods defined in a particular module, without just
doing the brute force thing of scanning all methods and filtering.

To address this, build on the deferred scanning code added in #57615 to
also add any scanned modules to an explicit list in `Module`. This costs
some space, but only proportional to the number of defined methods, (and
thus proportional to the written source code).

Note that we don't actually observe any issues in the test suite on
master due to this bug. However, this is because we are grossly
over-invalidating, which hides the missing invalidations from this issue
(#57617).

(cherry picked from commit 274d80e)
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.