JuliaPlots / JuliaPlots/PlotlyJS.jl

"using PlotlyJS" in atreplinit() runs atreplinit() twice

Open
#450 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
444
Forks
86
PR merge metrics
No merged PRs in 30d

Description

It is a common practice to add "using" directives to the atreplinit() function in startup.jl. However, adding "using PlotlyJS" to this function seems to silently run atreplinit() twice, which is potentially dangerous behaviour.

The initialization seems to belong to the same REPL object, and is likely linked to adding a display when the package is read.

Example startup.jl:

```
println("startup.jl start")

atreplinit() do repl

println("atreplinit() start")

print("repl object: ");
display(repr(UInt64(pointer_from_objref(repl))))

print("length of Base.Multimedia.displays: ")
display(length(Base.Multimedia.displays))

display(stacktrace())

println("*** using PlotlyJS ***")
eval( Meta.parse( "using PlotlyJS" ) )
println("atreplinit() end")
end
println("startup.jl end")
```
output:

```
startup.jl start
startup.jl end
atreplinit() start
repl object: "0x00007f086aaa8f10"
length of Base.Multimedia.displays: 2
11-element Vector{Base.StackTraces.StackFrame}:
(::var"#1#2")(repl::REPL.LineEditREPL) at startup.jl:13
__atreplinit(repl::REPL.LineEditREPL) at client.jl:336
#invokelatest#2 at essentials.jl:708 [inlined]
invokelatest at essentials.jl:706 [inlined]
_atreplinit at client.jl:343 [inlined]
(::Base.var"#875#877"{Bool, Bool, Bool})(REPL::Module) at client.jl:386
#invokelatest#2 at essentials.jl:708 [inlined]
invokelatest at essentials.jl:706 [inlined]
run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) at client.jl:372
exec_options(opts::Base.JLOptions) at client.jl:302
_start() at client.jl:485
*** using PlotlyJS ***
atreplinit() end
atreplinit() start
repl object: "0x00007f086aaa8f10"
length of Base.Multimedia.displays: 3
11-element Vector{Base.StackTraces.StackFrame}:
(::var"#1#2")(repl::REPL.LineEditREPL) at startup.jl:13
__atreplinit(repl::REPL.LineEditREPL) at client.jl:336
#invokelatest#2 at essentials.jl:708 [inlined]
invokelatest at essentials.jl:706 [inlined]
_atreplinit at client.jl:343 [inlined]
(::Base.var"#875#877"{Bool, Bool, Bool})(REPL::Module) at client.jl:386
#invokelatest#2 at essentials.jl:708 [inlined]
invokelatest at essentials.jl:706 [inlined]
run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool) at client.jl:372
exec_options(opts::Base.JLOptions) at client.jl:302
_start() at client.jl:485
*** using PlotlyJS ***
atreplinit() end

```

Can be reproduced in Julia 1.6.4, 1.8.2 and PlotlyJS v0.18.10.

Julia Version 1.6.4
Commit 35f0c911f4 (2021-11-19 03:54 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD Ryzen 7 1700 Eight-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, znver1)

Status `~/.julia/environments/v1.6/Project.toml`
[f0f68f2c] PlotlyJS v0.18.10
[0f1e0344] WebIO v0.8.93

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.