Clearing all variable bindings in workspace


#1

In the following code, the first call to plot() is ok, but the second doesn’t work, indeed the second ‘using’ statement already throws loads of exceptions:

using Plots;
plot();
workspace();
using Plots;
plot();

So clearly workspace() doesn’t clear all variable bindings in the workspace. Is there any way to do this?


#2

I have similar problems with workspace() and PyPlot in julia v0.5. Either importing or “using” PyPlot (or trying to reload any module of my own that uses PyPlot) after calling workspace() causes a segfault.

The same happens if I replace PyPlot with PyCall (which PyPlot uses.) If I replace PyPlot with the Plots module (which uses PyPlot), I don’t get a segfault – but I get similar warnings and a LoadError that causes Plots to not work. I don’t have any problems with code that doesn’t involve PyCall, so I suspect the issue is there.

The error message looks like:

[details=Long Error Message:]

julia> import PyPlot

julia> workspace()

julia> import PyPlot

WARNING: Method definition !(Function) in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1746 overwritten in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1746.
WARNING: Method definition redirect_stderr(Function, Any) in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1615 overwritten in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1615.
WARNING: Method definition take!(Main.Base.AbstractIOBuffer) in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1713 overwritten in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1713.
WARNING: Method definition redirect_stdout(Function, Any) in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1615 overwritten in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1615.
WARNING: Method definition isnull(Any) in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1693 overwritten in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1693.
WARNING: Method definition redirect_stdin(Function, Any) in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1615 overwritten in module Compat at /home/brayden/.julia/v0.5/Compat/src/Compat.jl:1615.
WARNING: Method definition run(Function) in module BinDeps at /home/brayden/.julia/v0.5/BinDeps/src/BinDeps.jl:445 overwritten in module BinDeps at /home/brayden/.julia/v0.5/BinDeps/src/BinDeps.jl:445.
WARNING: Method definition macroexpand(Module, Any) in module MacroTools at /home/brayden/.julia/v0.5/MacroTools/src/utils.jl:64 overwritten in module MacroTools at /home/brayden/.julia/v0.5/MacroTools/src/utils.jl:64.

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
julia_type_to_llvm at /build/julia-Fy046j/julia-0.5.0/src/cgutils.cpp:318
mark_julia_const at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:641
emit_expr at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3140
emit_function at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:4691
jl_compile_linfo at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:809
emit_invoke at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:2684 [inlined]
emit_expr at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3162
emit_assignment at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:2977 [inlined]
emit_expr at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3185
emit_stmtpos at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3064
emit_function at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:4727
jl_compile_linfo at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:809
emit_invoke at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:2684 [inlined]
emit_expr at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3162
emit_assignment at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:2977 [inlined]
emit_expr at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3185
emit_stmtpos at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3064
emit_function at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:4727
jl_compile_linfo at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:809
emit_invoke at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:2684 [inlined]
emit_expr at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3162
emit_call at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:2750
emit_expr at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3172
emit_stmtpos at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:3064
emit_function at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:4727
jl_compile_linfo at /build/julia-Fy046j/julia-0.5.0/src/codegen.cpp:809
jl_compile_for_dispatch at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1310
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:184 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-Fy046j/julia-0.5.0/src/julia.h:1392 [inlined]
jl_module_run_initializer at /build/julia-Fy046j/julia-0.5.0/src/toplevel.c:83
jl_init_restored_modules at /build/julia-Fy046j/julia-0.5.0/src/dump.c:1994 [inlined]
_jl_restore_incremental at /build/julia-Fy046j/julia-0.5.0/src/dump.c:2560
_jl_restore_incremental at /build/julia-Fy046j/julia-0.5.0/src/dump.c:2498 [inlined]
jl_restore_incremental at /build/julia-Fy046j/julia-0.5.0/src/dump.c:2580
_include_from_serialized at ./loading.jl:150
_require_from_serialized at ./loading.jl:187
_require_search_from_serialized at ./loading.jl:217
unknown function (ip: 0x7f7718f514d0)
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
require at ./loading.jl:371
unknown function (ip: 0x7f7718dbcc3b)
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-Fy046j/julia-0.5.0/src/julia.h:1392 [inlined]
read_verify_mod_list at /build/julia-Fy046j/julia-0.5.0/src/dump.c:1843
_jl_restore_incremental at /build/julia-Fy046j/julia-0.5.0/src/dump.c:2514
_jl_restore_incremental at /build/julia-Fy046j/julia-0.5.0/src/dump.c:2498 [inlined]
jl_restore_incremental at /build/julia-Fy046j/julia-0.5.0/src/dump.c:2580
_include_from_serialized at ./loading.jl:150
_require_from_serialized at ./loading.jl:187
require_search_from_serialized at ./loading.jl:217
unknown function (ip: 0x7f7718f514d0)
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
require at ./loading.jl:371
unknown function (ip: 0x7f7718dbcc3b)
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-Fy046j/julia-0.5.0/src/julia.h:1392 [inlined]
eval_import_path
at /build/julia-Fy046j/julia-0.5.0/src/toplevel.c:402
eval_import_path at /build/julia-Fy046j/julia-0.5.0/src/toplevel.c:429 [inlined]
jl_toplevel_eval_flex at /build/julia-Fy046j/julia-0.5.0/src/toplevel.c:495 [inlined]
jl_toplevel_eval at /build/julia-Fy046j/julia-0.5.0/src/toplevel.c:580
jl_toplevel_eval_in_warn at /build/julia-Fy046j/julia-0.5.0/src/builtins.c:590
eval at ./boot.jl:234
unknown function (ip: 0x7f7718d6d53f)
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
eval_user_input at ./REPL.jl:64
unknown function (ip: 0x7f75075b3d96)
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
macro expansion at ./REPL.jl:95 [inlined]
#3 at ./event.jl:68
unknown function (ip: 0x7f75075b0f2f)
jl_call_method_internal at /build/julia-Fy046j/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-Fy046j/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-Fy046j/julia-0.5.0/src/julia.h:1392 [inlined]
start_task at /build/julia-Fy046j/julia-0.5.0/src/task.c:253
unknown function (ip: 0xffffffffffffffff)
Allocations: 4172987 (Pool: 4171878; Big: 1109); GC: 4
Segmentation fault (core dumped)[/details]