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

invoked signatures spuriously invalidate in precompilation #44320

Closed
timholy opened this issue Feb 23, 2022 · 0 comments · Fixed by #46715
Closed

invoked signatures spuriously invalidate in precompilation #44320

timholy opened this issue Feb 23, 2022 · 0 comments · Fixed by #46715
Labels
compiler:precompilation Precompilation of modules

Comments

@timholy
Copy link
Member

timholy commented Feb 23, 2022

(This is copied over from #43990 (comment))

When a method is called via invoke, the specialization might appear to be one that should be superseded, but this is not always the case. To demonstrate this, create two packages:

module PkgA

f(::Int) = 1
f(::Any) = 2

g() = invoke(f, Tuple{Any}, 0)

g()

end # module

and

module PkgB

using PkgA

PkgA.f(::Real) = 3

end # module

We incorrectly invalidate g when we load PkgB:

julia> using PkgA

julia> PkgA.g()
2

julia> m = which(PkgA.g, ())
g() in PkgA at /tmp/pkgv/PkgA/src/PkgA.jl:6

julia> mi = m.specializations[1]
MethodInstance for PkgA.g()

julia> mi.cache.max_world
0xffffffffffffffff

julia> using PkgB

julia> mi.cache.max_world
0x0000000000007a61

julia> PkgA.g()
2

This is incorrect because the code that should run is unchanged by loading PkgB.

@timholy timholy added the compiler:precompilation Precompilation of modules label Feb 23, 2022
timholy added a commit that referenced this issue Sep 12, 2022
This is a left-over piece of #46010, triggered by const args.
timholy added a commit that referenced this issue Sep 12, 2022
This is a left-over piece of #46010, triggered by const args.

Fixes #44320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant