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

very unsound assumptions about REPL state injection #3933

Open
vtjnash opened this issue Jun 22, 2024 · 5 comments · May be fixed by JuliaLang/julia#54890
Open

very unsound assumptions about REPL state injection #3933

vtjnash opened this issue Jun 22, 2024 · 5 comments · May be fixed by JuliaLang/julia#54890

Comments

@vtjnash
Copy link
Member

vtjnash commented Jun 22, 2024

This code runs on a thread, which makes this an unsafe data race to call this function:

if isdefined(Base, :active_repl)
repl_init(Base.active_repl)
else
atreplinit() do repl
if isinteractive() && repl isa REPL.LineEditREPL
isdefined(repl, :interface) || (repl.interface = REPL.setup_interface(repl))
repl_init(repl)
end
end
end
push!(empty!(REPL.install_packages_hooks), try_prompt_pkg_add)

It is VERY strongly inadvisable to have an __init__ function defined in this code, due to the unreliability of the environment it runs in, and the corruption this will cause to the REPL module.

@KristofferC
Copy link
Member

I'm missing a solution here. This is how external REPL modes are installed AFAIU.

@vtjnash
Copy link
Member Author

vtjnash commented Jun 22, 2024

You install REPL hooks by calling empty!? that doesn't seem very scalable 😭

@IanButterworth
Copy link
Member

empty! explained and fixed here #3934

@KristofferC
Copy link
Member

You install REPL hooks by calling empty!

You linked a much larger piece of code than that single one.

@vtjnash
Copy link
Member Author

vtjnash commented Jun 22, 2024

The other major mistake here is calling Base.active_repl and assuming that returns REPL.active_repl

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.

3 participants