-
Notifications
You must be signed in to change notification settings - Fork 112
Revising methods with external method tables fails #646
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
Comments
As I'm sure you can imagine, a reproducer would be lovely. What version of LoweredCodeUtils are you on? I assume that line is https://github.com/JuliaDebug/LoweredCodeUtils.jl/blob/ff8998f6151bce37bbf6a82ce72622e692fd8df3/src/signatures.jl#L175. Obviously I can extend the Union to include |
Yeah, sorry, was going to put up some additional details, but wanted to make a note as soon as I ran into the issue 🙂 I was using LoweredCodeUtils v2.1.2, so yeah that was the line. The basic reproducer is as follows: Base.Experimental.@MethodTable(method_table)
foo() = 1
Base.Experimental.@overlay method_table foo() = 2
bar() = foo() This fails to
The reason that the error is slightly different, is that in CUDA.jl/GPUCompiler.jl we use a wrapper macro that interpolates the Base.Experimental.@MethodTable(method_table)
foo() = 1
macro override(ex)
quote
Base.Experimental.@overlay $method_table $ex
end
end
@override foo() = 2
bar() = foo() This yields the error reported above. |
Does it work if you make it a It will still throw a Revise error ( |
A macro override(ex)
quote
Base.Experimental.@overlay $(GlobalRef(@__MODULE__, :method_table)) $ex
end
end
But why a GlobalRef? Wouldn't source code typically contain a Symbol or Expr? Changing the
Similarly, without the wrapper macro, making sure the method table is an Expr (by qualifying the module) gets past
So I guess this only needs a fix for the I quoted 'compatible' above, because even though Revise doesn't choke on these sources anymore, it incorrectly redefines methods. I guess that's the second part of this issue. Expected behavior: julia> Base.Experimental.@MethodTable(method_table)
julia> foo() = 1
julia> Base.Experimental.@overlay Main.method_table foo() = 2
julia> foo()
1
julia> Base.Experimental.@overlay Main.method_table foo() = 3
julia> foo()
1 Whereas putting this in a file and having Revise track it yields the following:
|
Is this still relevant or did the PR above fix it? |
Yes, this is still relevant. The PR just made it so that Revise doesn't error out, but it doesn't correctly handle overlay method tables. Let me demonstrate: Base.Experimental.@MethodTable(method_table)
foo() = 1
Base.Experimental.@overlay Main.method_table foo() = 2
function main()
println("Method in main method table:")
methods = Base._methods_by_ftype(Tuple{typeof(foo)}, nothing, 1, Base.get_world_counter())
display(Base.uncompressed_ir(methods[1].method))
println("Method in overlay method table:")
methods = Base._methods_by_ftype(Tuple{typeof(foo)}, method_table, 1, Base.get_world_counter())
display(Base.uncompressed_ir(methods[1].method))
return
end julia> using Revise
julia> Revise.includet("...")
julia> main()
Method in main method table:
CodeInfo(
@ /tmp/wip.jl:3 within `foo`
1 ─ return 1
)
Method in overlay method table:
CodeInfo(
@ /tmp/wip.jl:4 within `#foo`
1 ─ return 2
)
julia> # redefine `@overlay foo() = 2` to `@overlay foo() = 3`
julia> main()
Method in main method table:
CodeInfo(
@ /tmp/wip.jl:4 within `foo`
1 ─ return 3
)
Method in overlay method table:
CodeInfo(
@ /tmp/wip.jl:4 within `#foo`
1 ─ return 2
) i.e. revising the overlaid method results in the main method table method being redefined, instead of the one on the overlay method table. |
I tried to investigate this a bit:
Don't know how big of a problem this is. On the other hand if I print here:
|
The error is from JuliaInterpreter:
Some info from around the error:
key
is CUDA.jl's external method table with all device-specific functions.This is on Julia 1.7, with Revise 3.1.19 and JuliaInterpreter 0.8.21.
The text was updated successfully, but these errors were encountered: