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

Base.active_module() design is very badly broken on master #54888

Closed
vtjnash opened this issue Jun 22, 2024 · 3 comments · Fixed by #55316
Closed

Base.active_module() design is very badly broken on master #54888

vtjnash opened this issue Jun 22, 2024 · 3 comments · Fixed by #55316
Assignees
Labels
regression 1.11 Regression in the 1.11 release regression 1.12 Regression in the 1.12 release
Milestone

Comments

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jun 22, 2024

In addition to existing milestone-blocking issues with Base.active_module function being broken and thread-unsafe, it can also outright crash the session if it gets into a slightly bad state:

[ Info: Precompiling REPLExt [e5eb5ef1-03cf-53a7-ae1d-5a66b08e832b] 
ERROR: TypeError: 
Stacktrace:
  [1] active_module()
    @ REPL ~/julia/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:630
  [2] #invokelatest#2
    @ ./essentials.jl:1045 [inlined]
  [3] invokelatest
    @ ./essentials.jl:1042 [inlined]
  [4] active_module
    @ ./show.jl:519 [inlined]
  [5] 
SYSTEM (REPL): showing an error caused an error
ERROR: TypeError: 
Stacktrace:
  [1] active_module()
    @ REPL ~/julia/usr/share/julia/stdlib/v1.12/REPL/src/REPL.jl:630
  [2] #invokelatest#2
    @ ./essentials.jl:1045 [inlined]
  [3] invokelatest
    @ ./essentials.jl:1042 [inlined]
  [4] active_module
    @ ./show.jl:519 [inlined]
  [5] 
SYSTEM (REPL): caught exception of type TypeError while trying to handle a nested exception; giving up

julia> Base.active_module()

SYSTEM: caught exception of type :TypeError while trying to print a failed Task notice; giving up
ERROR: TaskFailedException
Stacktrace:
  [1] fatal: error thrown and no exception handler available.
TypeError(func=:typeassert, context="", expected=REPL.AbstractREPL, got=REPL.LineEditREPL(t=REPL.Terminals.TTYTerminal(term_type="xterm-256color", in_stream=Base.TTY(handle=0x000000012ef05da0, status=3, buffer=Base.GenericIOBuffer{Memory{UInt8}}(data=Memory{UInt8}(65536, 0x120600048)[0x28, 0x5b, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00
# this keeps printing until the terminal crashes
@vtjnash vtjnash added this to the 1.12 milestone Jun 22, 2024
vtjnash added a commit that referenced this issue Jun 24, 2024
This fixes a couple unconventional issues people encountered and were
able to report as bugs against #54739

Note that due to several bugs in REPLExt itself
(#54889,
#54888), loading the extension
may still crash julia in some circumstances, but that is now a Pkg bug,
and no longer the fault of the loading code.
@KristofferC
Copy link
Sponsor Member

The assumptions for how the loading system now works with the new "upgradable stdlib" stuff is only known by one person now I think so I assign this to that one person heh.

KristofferC pushed a commit that referenced this issue Jul 23, 2024
This fixes a couple unconventional issues people encountered and were
able to report as bugs against #54739

Note that due to several bugs in REPLExt itself
(#54889,
#54888), loading the extension
may still crash julia in some circumstances, but that is now a Pkg bug,
and no longer the fault of the loading code.

(cherry picked from commit a7fa1e7)
@nsajko
Copy link
Contributor

nsajko commented Jul 30, 2024

On NixOS, but not (?) on Arch, this affects v1.11, not just nightly: #55309

@nsajko nsajko modified the milestones: 1.12, 1.11 Jul 30, 2024
@nsajko nsajko added regression 1.11 Regression in the 1.11 release regression 1.12 Regression in the 1.12 release labels Jul 30, 2024
@KristofferC
Copy link
Sponsor Member

AFAIU, the issue is that we have two REPL modules loaded and Base.active_repl will be a different type of REPL than what is type asserted at

return active_module(Base.active_repl::AbstractREPL)
.

Basically, there is a mismatch between Base.active_repl and Base.REPL_MODULE_REF[]?

lazarusA pushed a commit to lazarusA/julia that referenced this issue Aug 17, 2024
…module` (JuliaLang#55316)

also avoid calling `active_module` from low-level printing functions
fix JuliaLang#54888
KristofferC pushed a commit that referenced this issue Sep 12, 2024
…module` (#55316)

also avoid calling `active_module` from low-level printing functions
fix #54888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression 1.11 Regression in the 1.11 release regression 1.12 Regression in the 1.12 release
Projects
None yet
3 participants