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

redefinition of constant bug when using @require #736

Closed
t-bltg opened this issue Mar 2, 2023 · 3 comments
Closed

redefinition of constant bug when using @require #736

t-bltg opened this issue Mar 2, 2023 · 3 comments

Comments

@t-bltg
Copy link
Collaborator

t-bltg commented Mar 2, 2023

Reduced case for JuliaPlots/UnicodePlots.jl#334, code available here: https://github.com/t-bltg/Ext.jl.

On julia versions < 1.9 (this bug does not occur on 1.9.0-betaX):

without Revise

julia> VERSION
v"1.8.5"
julia> using FreeType
julia> using Ext
Ext __init__
FreeTypeExt include
FreeTypeExt __init__

with Revise

julia> VERSION
v"1.8.5"
julia> using Revise
julia> using FreeType
julia> using Ext
Ext __init__
FreeTypeExt include
FreeTypeExt __init__
FreeTypeExt include
WARNING: redefinition of constant VALID_FONTPATHS. This may fail, cause incorrect answers, or produce other errors.

Note that when using Revise, include is called twice on the extension module while __init__ only once, causing redefinition warnings and errors in the full UnicodePlots report.

@t-bltg
Copy link
Collaborator Author

t-bltg commented Apr 9, 2023

Here is the full stacktrace:

julia> using Revise, FreeType, Ext
Ext __init__
FreeTypeExt include
top-level scope at Ext.jl:9
eval at boot.jl:368 [inlined]
eval at Ext.jl:1 [inlined]
(::Ext.var"#3#6")() at require.jl:101
macro expansion at timing.jl:382 [inlined]
err(f::Any, listener::Module, modname::String, file::String, line::Any) at require.jl:47
(::Ext.var"#2#5")() at require.jl:100
withpath(f::Any, path::String) at require.jl:37
(::Ext.var"#1#4")() at require.jl:99
listenpkg(f::Any, pkg::Base.PkgId) at require.jl:20
macro expansion at require.jl:98 [inlined]
__init__() at Ext.jl:7
_include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any}) at loading.jl:831
_require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64) at loading.jl:1039
_require(pkg::Base.PkgId) at loading.jl:1315
_require_prelocked(uuidkey::Base.PkgId) at loading.jl:1200
macro expansion at loading.jl:1180 [inlined]
macro expansion at lock.jl:223 [inlined]
require(into::Module, mod::Symbol) at loading.jl:1144
eval at boot.jl:368 [inlined]
eval_user_input(ast::Any, backend::REPL.REPLBackend) at REPL.jl:151
repl_backend_loop(backend::REPL.REPLBackend) at REPL.jl:247
start_repl_backend(backend::REPL.REPLBackend, consumer::Any) at REPL.jl:232
run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool) at REPL.jl:369
run_repl(repl::REPL.AbstractREPL, consumer::Any) at REPL.jl:355
(::Base.var"#967#969"{Bool, Bool, Bool})(REPL::Module) at client.jl:419
#invokelatest#2 at essentials.jl:729 [inlined]
invokelatest at essentials.jl:726 [inlined]
run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) at client.jl:404
exec_options(opts::Base.JLOptions) at client.jl:318
_start() at client.jl:522
FreeTypeExt __init__
┌ Debug: Requires conditionally ran code in 1.506112428 seconds: `Ext` detected `FreeType`
└ @ Requires /exports/shared/__tmp__/Ext.jl/src/Ext.jl:7
FreeTypeExt include
invoke_in_world(::UInt64, ::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at essentials.jl:763
invoke_in_world(::UInt64, ::Any, ::Any, ::Vararg{Any}) at essentials.jl:760
bypass_builtins(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr, pc::Int64) at interpret.jl:195
evaluate_call_recurse!(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr; enter_generated::Bool) at interpret.jl:222
evaluate_call_recurse! at interpret.jl:220 [inlined]
eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr) at interpret.jl:393
step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool) at interpret.jl:546
step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at interpret.jl:596
finish!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at commands.jl:14
finish_and_return!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at commands.jl:30
evaluate_call_recurse!(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr; enter_generated::Bool) at interpret.jl:260
evaluate_call_recurse! at interpret.jl:220 [inlined]
eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr) at interpret.jl:393
step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool) at interpret.jl:546
step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at interpret.jl:596
finish!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at commands.jl:14
finish_and_return!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at commands.jl:30
evaluate_call_recurse!(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr; enter_generated::Bool) at interpret.jl:260
evaluate_call_recurse! at interpret.jl:220 [inlined]
eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr) at interpret.jl:393
step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool) at interpret.jl:546
step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at interpret.jl:596
finish!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at commands.jl:14
finish_and_return!(recurse::Any, frame::JuliaInterpreter.Frame, istoplevel::Bool) at commands.jl:30
evaluate_call_recurse!(recurse::Any, frame::JuliaInterpreter.Frame, call_expr::Expr; enter_generated::Bool) at interpret.jl:260
evaluate_call_recurse! at interpret.jl:220 [inlined]
eval_rhs(recurse::Any, frame::JuliaInterpreter.Frame, node::Expr) at interpret.jl:393
step_expr!(recurse::Any, frame::JuliaInterpreter.Frame, node::Any, istoplevel::Bool) at interpret.jl:541
methods_by_execution!(recurse::Any, methodinfo::Revise.CodeTrackingMethodInfo, docexprs::Dict{Module, Vector{Expr}}, frame::JuliaInterpreter.Frame, isrequired::Vector{Bool}; mode::Symbol, skip_include::Bool) at lowered.jl:447
methods_by_execution! at lowered.jl:238 [inlined]
methods_by_execution!(recurse::Any, methodinfo::Revise.CodeTrackingMethodInfo, docexprs::Dict{Module, Vector{Expr}}, mod::Module, ex::Expr; mode::Symbol, disablebp::Bool, always_rethrow::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at lowered.jl:217
methods_by_execution! at lowered.jl:173 [inlined]
#eval_with_signatures#91 at packagedef.jl:471 [inlined]
eval_with_signatures at packagedef.jl:468 [inlined]
(::Revise.var"#83#85"{Symbol, Revise.RelocatableExpr, OrderedCollections.OrderedDict{Revise.RelocatableExpr, Union{Nothing, Vector{Any}}}, Module})() at packagedef.jl:326
with_logstate(f::Function, logstate::Any) at logging.jl:511
with_logger at logging.jl:623 [inlined]
#eval_rex#82 at packagedef.jl:318 [inlined]
eval_rex at packagedef.jl:317 [inlined]
eval_new!(exs_sigs_new::OrderedCollections.OrderedDict{Revise.RelocatableExpr, Union{Nothing, Vector{Any}}}, exs_sigs_old::OrderedCollections.OrderedDict{Revise.RelocatableExpr, Union{Nothing, Vector{Any}}}, mod::Module; mode::Symbol) at packagedef.jl:369
eval_new! at packagedef.jl:366 [inlined]
eval_new!(mod_exs_sigs_new::OrderedCollections.OrderedDict{Module, OrderedCollections.OrderedDict{Revise.RelocatableExpr, Union{Nothing, Vector{Any}}}}, mod_exs_sigs_old::OrderedCollections.OrderedDict{Module, OrderedCollections.OrderedDict{Revise.RelocatableExpr, Union{Nothing, Vector{Any}}}}; mode::Symbol) at packagedef.jl:388
eval_new! at packagedef.jl:380 [inlined]
eval_require_now(pkgdata::Revise.PkgData, fileidx::Int64, filekey::String, sourcefile::String, modcaller::Module, expr::Expr) at pkgs.jl:274
#invokelatest#2 at essentials.jl:729 [inlined]
invokelatest at essentials.jl:726 [inlined]
add_require(sourcefile::String, modcaller::Module, idmod::String, modname::String, expr::Expr) at pkgs.jl:229
withnotifications(::Any, ::Vararg{Any}) at require.jl:70
(::Ext.var"#1#4")() at require.jl:106
listenpkg(f::Any, pkg::Base.PkgId) at require.jl:20
macro expansion at require.jl:98 [inlined]
__init__() at Ext.jl:7
_include_from_serialized(pkg::Base.PkgId, path::String, depmods::Vector{Any}) at loading.jl:831
_require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt64) at loading.jl:1039
_require(pkg::Base.PkgId) at loading.jl:1315
_require_prelocked(uuidkey::Base.PkgId) at loading.jl:1200
macro expansion at loading.jl:1180 [inlined]
macro expansion at lock.jl:223 [inlined]
require(into::Module, mod::Symbol) at loading.jl:1144
eval at boot.jl:368 [inlined]
eval_user_input(ast::Any, backend::REPL.REPLBackend) at REPL.jl:151
repl_backend_loop(backend::REPL.REPLBackend) at REPL.jl:247
start_repl_backend(backend::REPL.REPLBackend, consumer::Any) at REPL.jl:232
run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool) at REPL.jl:369
run_repl(repl::REPL.AbstractREPL, consumer::Any) at REPL.jl:355
(::Base.var"#967#969"{Bool, Bool, Bool})(REPL::Module) at client.jl:419
#invokelatest#2 at essentials.jl:729 [inlined]
invokelatest at essentials.jl:726 [inlined]
run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) at client.jl:404
exec_options(opts::Base.JLOptions) at client.jl:318
_start() at client.jl:522
WARNING: redefinition of constant VALID_FONTPATHS. This may fail, cause incorrect answers, or produce other errors.

@timholy
Copy link
Owner

timholy commented Jan 1, 2024

On Julia 1.10, with current versions of Revise (3.5.11) & LoweredCodeUtils (2.4.2), I can't replicate this.

@t-bltg
Copy link
Collaborator Author

t-bltg commented Jan 2, 2024

Yes, this bug only occurs on versions < 1.9.

Thanks @timholy , I think we can probably close this issue now.

@t-bltg t-bltg closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants