Skip to content

bpart: failed "edge" invalidation #58336

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

Merged
merged 2 commits into from
May 10, 2025
Merged

bpart: failed "edge" invalidation #58336

merged 2 commits into from
May 10, 2025

Conversation

timholy
Copy link
Member

@timholy timholy commented May 7, 2025

This adds a test for an invalidation failure when consts are redefined. The failure occurs only in "edge" mode, i.e., due to the separation of precompilation from the user's running session.

The corresponding "immediate" sequence is the following (which seems to work properly):

julia> struct InvalidatedBinding
           x::Int
       end

julia> struct Wrapper
           ib::InvalidatedBinding
       end

julia> makewib(x) = Wrapper(InvalidatedBinding(x))
makewib (generic function with 1 method)

julia> const gib = makewib(1)
Wrapper(InvalidatedBinding(1))

julia> fib() = gib.ib.x
fib (generic function with 1 method)

julia> fib()
1

julia> ci = only(methods(fib)).specializations.cache
CodeInstance for MethodInstance for fib()

julia> struct InvalidatedBinding
           x::Float64
       end

julia> ci.max_world
0xffffffffffffffff

julia> struct Wrapper
           ib::InvalidatedBinding
       end

julia> const gib = makewib(2.0)
Wrapper(InvalidatedBinding(2.0))

julia> ci.max_world
0x0000000000009789

julia> fib() === 2.0
true

But it fails when the precompilation of fib happens in a package that gets loaded after gib is redefined in the user's session.

@timholy timholy added the DO NOT MERGE Do not merge this PR! label May 7, 2025
@timholy timholy added this to the 1.12 milestone May 7, 2025
@timholy timholy added the bug Indicates an unexpected problem or unintended behavior label May 7, 2025
Co-authored-by: Jameson Nash <[email protected]>
@timholy timholy removed the DO NOT MERGE Do not merge this PR! label May 7, 2025
@timholy timholy removed this from the 1.12 milestone May 7, 2025
@timholy timholy added the merge me PR is reviewed. Merge when all tests are passing label May 7, 2025
@timholy
Copy link
Member Author

timholy commented May 7, 2025

I took it off the milestone and slapped a "merge me" on it, but once merged we should make a milestone item to turn those @test_brokens into @test. EDIT: done in #58346.

@@ -956,6 +956,17 @@ precompile_test_harness("code caching") do dir
use_stale(c) = stale(c[1]) + not_stale("hello")
build_stale(x) = use_stale(Any[x])

# bindings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests for this code path are mostly in rebinding.jl. I don't really mind it being here, but I don't fully know yet what distinguishes this case from the ones already tested

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I hadn't found that yet. Likewise I'd have no objection to moving these tests to rebinding.jl.

Copy link
Member Author

@timholy timholy May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One potential difference: from a quick scan, the tests in rebinding.jl seem to define the function in the same module in which it's precompiled. This test defines StaleA.fib() but defers its precompilation until StaleB, and yanks the rug out in between loading those two modules.

@timholy timholy merged commit c13ea2b into master May 10, 2025
5 of 9 checks passed
@timholy timholy deleted the teh/bpart-edgeinval branch May 10, 2025 14:30
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label May 11, 2025
charleskawczynski pushed a commit to charleskawczynski/julia that referenced this pull request May 12, 2025
This adds a test for an invalidation failure when `consts` are
redefined. The failure occurs only in "edge" mode, i.e., due to the
separation of precompilation from the user's running session.
@KristofferC KristofferC added the backport 1.12 Change should be backported to release-1.12 label Jul 8, 2025
KristofferC pushed a commit that referenced this pull request Jul 8, 2025
This adds a test for an invalidation failure when `consts` are
redefined. The failure occurs only in "edge" mode, i.e., due to the
separation of precompilation from the user's running session.

(cherry picked from commit c13ea2b)
@KristofferC KristofferC mentioned this pull request Jul 8, 2025
60 tasks
@KristofferC KristofferC removed the backport 1.12 Change should be backported to release-1.12 label Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants