Skip to content

minimal evaluation for loading.jl makes Julia internals broken #903

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

Closed
aviatesk opened this issue Apr 17, 2025 · 6 comments · Fixed by #910
Closed

minimal evaluation for loading.jl makes Julia internals broken #903

aviatesk opened this issue Apr 17, 2025 · 6 comments · Fixed by #910

Comments

@aviatesk
Copy link
Collaborator

It seems like the minimal evaluation in Revise isn't working correctly against loading.jl (probably due to an issue with LoweredCodeUtils?).

I've confirmed that this problem exists in v1.12 with the master branch of Revise/LoweredCodeUtils.jl.
I've also seen the issue even when using the PR that updates LCU.jl to be compatible with 1.12.

We can reproduce the problem like this:
If we run maybe_extract_sigs! on loading.jl, the Pkg prompt gets messed up. After that, commands like st will result in errors.

julia> using Revise

julia> let pkgid = Revise.get_tracked_id(Base)
           filename = "loading.jl"
           pkgdata = Revise.pkgdatas[pkgid]
           Revise.maybe_extract_sigs!(Revise.maybe_parse_from_cache!(pkgdata, filename))
       end;
[ Info: tracking Base

pkg> st # weird things happen when entering pkg mode
ERROR: SystemError: getattrlist: Invalid argument
Stacktrace:
  [1] systemerror(p::Symbol, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:186
  [2] systemerror
    @ ./error.jl:185 [inlined]
  [3] isfile_casesensitive(path::String)
    @ Base ~/julia/julia4/base/loading.jl:56
  [4] active_project(search_load_path::Bool)
    @ Base ./initdefs.jl:347
  [5] active_project
    @ ./initdefs.jl:340 [inlined]
  [6] find_project_file(env::Nothing)
    @ Pkg.Types ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/Types.jl:203
  [7] Pkg.Types.EnvCache(env::Nothing)
    @ Pkg.Types ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/Types.jl:382
  [8] EnvCache
    @ ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/Types.jl:382 [inlined]
  [9] Context
    @ ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/Types.jl:444 [inlined]
 [10] status(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IO}, kwargs::@Kwargs{})
    @ Pkg.API ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/API.jl:155
 [11] status(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/API.jl:153
 [12] do_cmd(command::Pkg.REPLMode.Command, io::Base.TTY)
    @ Pkg.REPLMode ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/REPLMode/REPLMode.jl:409
 [13] do_cmds(commands::Vector{Pkg.REPLMode.Command}, io::Base.TTY)
    @ Pkg.REPLMode ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/src/REPLMode/REPLMode.jl:395
 [14] do_cmds(repl::REPL.LineEditREPL, commands::String)
    @ REPLExt ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/ext/REPLExt/REPLExt.jl:99
 [15] on_done(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool, repl::REPL.LineEditREPL)
    @ REPLExt ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/ext/REPLExt/REPLExt.jl:113
 [16] apply_gr(::GlobalRef, ::Any, ::Vararg{Any})
    @ Base ./reflection.jl:1278
 [17] #invokelatest_gr#232
    @ ./reflection.jl:1285 [inlined]
 [18] invokelatest_gr
    @ ./reflection.jl:1281 [inlined]
 [19] (::REPLExt.var"#create_mode##0#create_mode##1"{REPL.LineEditREPL})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ REPLExt ~/julia/julia4/usr/share/julia/stdlib/v1.12/Pkg/ext/REPLExt/REPLExt.jl:135
 [20] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/julia/julia4/usr/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2852
 [21] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/julia/julia4/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:1657
 [22] (::REPL.var"#61#62"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/julia/julia4/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:648
@timholy
Copy link
Owner

timholy commented Apr 19, 2025

Have you checked this on #894 yet? I've seem some things like this before but not since I've been running with that PR. But I don't think I checked loading.jl specifically.

@aviatesk
Copy link
Collaborator Author

Whoops, this issue seems to have been fixed on #894!

@timholy
Copy link
Owner

timholy commented Apr 19, 2025

No "whoops" needed, that's not merged yet.

My guess is that it's the change in #894 that made

Revise.jl/src/lowered.jl

Lines 454 to 456 in 5105f0a

elseif LoweredCodeUtils.get_lhs_rhs(stmt) !== nothing
# If we're here, either isrequired[pc] is true, or the mode forces us to eval assignments
pc = step_expr!(recurse, frame, stmt, true)
conditional on mode:

               if mode === :sigs && stmt.head === :const && (a = stmt.args[1]) isa GlobalRef && @invokelatest(isdefined(mod, a.name))
                    # avoid redefining types unless we have to
                    pc = next_or_nothing!(frame)
                else
                    pc = step_expr!(recurse, frame, stmt, true)
                end

I guess that wasn't an issue before bpart, but we could consider making that change independently of #894.

aviatesk referenced this issue in aviatesk/JET.jl Apr 19, 2025
@aviatesk
Copy link
Collaborator Author

Yes, that's right.
I confirmed that changing that part fixes the issue in master with the above repro.
It would be very helpful if you could merge this soon, separate from #894.

timholy added a commit that referenced this issue Apr 19, 2025
Fixes #903

This is split out from #894.
@timholy
Copy link
Owner

timholy commented Apr 19, 2025

xref #910

timholy added a commit that referenced this issue Apr 19, 2025
@timholy
Copy link
Owner

timholy commented Apr 19, 2025

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

Successfully merging a pull request may close this issue.

2 participants