JuliaLang / Pkg.jl

Pkg - Package manager for the Julia programming language
https://pkgdocs.julialang.org
Other
609 stars 251 forks source link

very unsound assumptions about REPL state injection #3933

Open vtjnash opened 1 week ago

vtjnash commented 1 week ago

This code runs on a thread, which makes this an unsafe data race to call this function: https://github.com/JuliaLang/Pkg.jl/blob/8c996799b0ae3d6cccf8a5f25744deb6640adb9e/ext/REPLExt/REPLExt.jl#L311-L321

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 commented 1 week ago

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

vtjnash commented 1 week ago

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

IanButterworth commented 1 week ago

empty! explained and fixed here https://github.com/JuliaLang/Pkg.jl/pull/3934

KristofferC commented 1 week ago

You install REPL hooks by calling empty!

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

vtjnash commented 1 week ago

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