Skip to content

REPL: call display on the backend #57773

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

Merged

Conversation

IanButterworth
Copy link
Member

Fixes #57742

With this PR (The last 2 are pasted in in one operation)

% ./julia -q -t8,0

julia> struct Foo end

julia> Base.display(::Foo) = @show Threads.threadid()

julia> Foo()
Threads.threadid() = 1

julia> Foo()
Threads.threadid() = 1

julia> Foo()
Threads.threadid() = 1

julia> Foo()
Threads.threadid() = 1

@IanButterworth IanButterworth added REPL Julia's REPL (Read Eval Print Loop) backport 1.11 Change should be backported to release-1.11 backport 1.12 Change should be backported to release-1.12 labels Mar 14, 2025
@IanButterworth
Copy link
Member Author

Though I think handling errors in display might need a tweak.

julia> Base.display(::Foo) = error()

julia> Foo()

julia> Foo()

julia>

@IanButterworth IanButterworth requested a review from vtjnash March 14, 2025 14:18
@giordano giordano linked an issue Mar 14, 2025 that may be closed by this pull request
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branching on whether the parser returned an Expr or a Function seems somewhat unwise, but otherwise the PR seems a good direction

@IanButterworth IanButterworth force-pushed the ib/repl_display_backend branch 4 times, most recently from ddd9e16 to 8d77b53 Compare March 20, 2025 04:04
@IanButterworth IanButterworth force-pushed the ib/repl_display_backend branch from 8d77b53 to 424a5ce Compare March 22, 2025 02:08
@IanButterworth IanButterworth added the merge me PR is reviewed. Merge when all tests are passing label Mar 22, 2025
@IanButterworth IanButterworth merged commit c75cf3f into JuliaLang:master Mar 23, 2025
8 checks passed
KristofferC pushed a commit that referenced this pull request Mar 24, 2025
@KristofferC KristofferC mentioned this pull request Mar 24, 2025
27 tasks
@KristofferC KristofferC removed the backport 1.12 Change should be backported to release-1.12 label Mar 31, 2025
KristofferC pushed a commit that referenced this pull request Mar 31, 2025
@KristofferC KristofferC mentioned this pull request Mar 31, 2025
71 tasks
@KristofferC KristofferC removed the backport 1.11 Change should be backported to release-1.11 label Apr 10, 2025
@KristofferC
Copy link
Member

I think this broke Debugger.jl.

julia> f(a,b) = a+b
f (generic function with 1 method)

julia> @enter f(4, 5)
In f(a, b) at REPL[4]:1
>1  f(a,b) = a+b

About to run: (+)(4, 5)
1|julia> a < HANGS>
# Force interrupt:
^CERROR: InterruptException:
Stacktrace:
  [1] poptask(W::Base.IntrusiveLinkedListSynchronized{Task})
    @ Base ./task.jl:1012
  [2] wait()
    @ Base ./task.jl:1021
  [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
    @ Base ./condition.jl:130
  [4] wait
    @ ./condition.jl:125 [inlined]
  [5] take_buffered(c::Channel{Any})
    @ Base ./channels.jl:493
  [6] take!
    @ ./channels.jl:487 [inlined]
  [7] eval_with_backend
    @ ~/.julia/juliaup/julia-1.11.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1006 [inlined]
  [8] print_response(errio::IO, response::Any, backend::Union{…}, show_value::Bool, have_color::Bool, specialdisplay::Union{…})
    @ REPL ~/.julia/juliaup/julia-1.11.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:436
  [9] (::REPL.var"#70#71"{REPL.LineEditREPL, Tuple{Int64, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/.julia/juliaup/julia-1.11.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:405
 [10] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/.julia/juliaup/julia-1.11.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/REPL/src/REPL.jl:678

This is what Debugger does: https://github.com/JuliaDebug/Debugger.jl/blob/6a6beab2f559a5a72d3284c1c6482e0620026db8/src/repl.jl#L194.

Should it be changed somehow?

@oscardssmith
Copy link
Member

@KristofferC I believe this is fixed by JuliaDebug/Debugger.jl#366 (but I would appreciate review since the intent here is highly unclear)

@IanButterworth
Copy link
Member Author

I think the fix should be to figure out and fix why it's hanging, not avoid that method. But I haven't had time to look into this yet. I don't have any breadcrumbs right now, sorry.

@oscardssmith
Copy link
Member

should we revert the backport to 1.11? This is in 1.11.5 (already released), and breaking Debugger is pretty bad...

@IanButterworth
Copy link
Member Author

I think we just need to async call print_response and wait for it

@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REPL: display should only ever be called on the repl backend task
5 participants